哦,亲爱的,在我头上没有头发之前请帮忙!
首先,这是我的代码:
private void copyDatabase() {
if(!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())){
Toast.makeText(this, "External SD card not mounted", Toast.LENGTH_LONG).show();
}
//Toast Message Always appears
try {
InputStream in = getAssets().open("Asset_Directory");
File outFile = new File(Environment.getExternalStorageDirectory() + File.separator + "Asset_Directory");
outFile.createNewFile();
OutputStream out = new FileOutputStream(outFile);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
in.close();
Log.i("AssetCaptureActivity","Database has been transferred");
} catch (IOException e) {
Log.i("AssetCaptureActivity","Could not open the file");
}
}`
如您所见:我将一个数据库文件复制到我的 Assets 文件夹中。现在我想将它复制到虚拟 sd 卡,以便我可以编辑数据库。我在清单中添加了 WRITE 权限。我读到我需要更改我的 [运行配置] 设置中的某些内容 - 但是什么?
我不断收到 Permission Denied,它说我的 sd 卡没有安装。
请帮忙!