我正在尝试导出一些 SQLite 表数据。我收到 IOException: /TestFileExport0719a.csv: open failed: EROFS (Read-only file system)
下面是我的代码:
Boolean returnCode = false;
int i = 0;
String csvValues = "";
dbadapter = new DBAdapter(this);
dbadapter.open();
try {
File outFile = new File(outFileName);
FileWriter fileWriter = new FileWriter(outFile);
BufferedWriter out = new BufferedWriter(fileWriter);
Cursor cursor = dbadapter.getAllSkus();
if (cursor != null) {
while (cursor.moveToNext()) {
csvValues = Long.toString(cursor.getLong(0)) + ",";
csvValues += cursor.getString(1)
+ ",";
csvValues += cursor.getString(2)
+ "\n";
out.write(csvValues);
}
cursor.close();
}
out.close();
returnCode = true;
} catch (IOException e) {
returnCode = false;
Log.d(TAG, "IOException: " + e.getMessage());
}
dbadapter.close();
return returnCode;
设备未植根。任何帮助,将不胜感激。
谢谢
更改为后出现以下错误:
文件 outFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), outFileName);
07-20 18:31:07.595:D/BackupCSV(1580):IOException:/storage/emulated/0/Download/TestFileExport0719a.csv:打开失败:EACCES(权限被拒绝)
编辑-
在清单中添加权限解决了这个问题。
谢谢您的帮助。