使用
Runtime.getRuntime().exec("cp file:///android_asset/* /mnt/sdcard/images/");
用上面的方法提示说权限不足我尝试了下用输入输出流先把assets的文件读入到输入流,再用输出流写到sdcard中,这样是可以的,除此之外还有别的方法吗?如果文件多的话,这样作效率很低的
Runtime.getRuntime().exec("cp file:///android_asset/* /mnt/sdcard/images/");
用上面的方法提示说权限不足我尝试了下用输入输出流先把assets的文件读入到输入流,再用输出流写到sdcard中,这样是可以的,除此之外还有别的方法吗?如果文件多的话,这样作效率很低的
解决方案 »
- android简单的计算器有错,求好心人帮忙(80分)
- android如何得到服务端的返回值 集合类型
- ADT插件检测不到g7,应该装什么驱动
- 还是socket问题,收到的数据不对
- 我们中国做开发的出路在哪里
- Android 4.0或以上的源码谁有啊?
- unfortunately, Settings has stopped这句提示信息是在源代码哪里弹出来的?
- 关于开发环境的问题 我都郁闷死了
- 那些c++搞android 的,后来都怎么样了。
- Android Q beta版下怎么调用系统相册图片?
- android popupwindow 浮动在所有activity之上
- 求教写Android.mk文件
File file = new File("/data/data/" + getPackageName() + "/databases/",
Utils.GLOBALDB+".db");
file.getParentFile().mkdirs();
if(file.exists())
return;
InputStream in;
OutputStream out;
try {
in = getAssets().open(Utils.GLOBALDB+".db");
out = new FileOutputStream(file); byte[] buff = new byte[1024];
int len;
while ((len = in.read(buff)) > 0) {
out.write(buff, 0, len);
}
out.close();
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
File file = new File("/mnt/sdcard/filename");
file.getParentFile().mkdirs();
if(file.exists())
return;
InputStream in;
OutputStream out;
try {
in = getAssets().open(Utils.GLOBALDB+".db");
out = new FileOutputStream(file); byte[] buff = new byte[1024];
int len;
while ((len = in.read(buff)) > 0) {
out.write(buff, 0, len);
}
out.close();
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
将路径写入了数据库,然后拷贝到sdcard上,最读sdcard里面的数据库信息就可以拉
但是Runtime.getRuntime().exec("cp file:///android_asset/* /mnt/sdcard/images/");
这个命令是linux命令
你可以试试Runtime.getRuntime().exec("cp assets/* /mnt/sdcard/images/");
Runtime.getRuntime().exec("cp /data/data/apk的包名/res/assets/* /mnt/sdcard/images/");