I'm trying to export some SQLite table data. I'm getting the IOException: /TestFileExport0719a.csv: open failed: EROFS (Read-only file system)
Below is my code:
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;
The devices are not rooted. Any help would be appreciated.
Thanks
I get the following error after I made the change to:
File 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: open failed: EACCES (Permission denied)
Edit-
Adding the permission in the manifest fixed the problem.
Thanks for the help.