我正在尝试编写一个简单的测试方法将文件从 Asset 文件夹复制到 sd 卡。当我尝试打开 sd 卡上的文件时,它崩溃了。
代码
try {
// POpne file from asset
AssetManager assetManager = getAssets();
InputStream inputStream;
inputStream = assetManager.open("test");
// open output folder
File externalStorage = Environment.getExternalStorageDirectory();
// CRASHES HERE
out = new FileOutputStream( externalStorage.getAbsolutePath() );
int c;
while ((c = inputStream.read()) != -1) {
out.write(c);
}
} catch( Exception e) {
}
}