I'm trying to export my custom SQLite database into an Excel-readable format. I am using the method suggested here to convert my .db to a .csv. The code seems to work well, I get no exceptions thrown and the CSVWriter
says that the file was exported successfully. I am exporting to Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).
However, when I open the Downloads folder on the device, I don't see any .csv files.
I checked my code by writing a simple text file, and the text file shows up in the same directory, but not the .csv file. Also, my database is tested with System print, it is not empty - it is working and storing info properly.
Any clues? Am I missing something? My database is using fts3
, could that affect this? Here's code that creates the .csv file before copying the database:
protected Boolean doInBackground(final String... args)
{
File dbFile=getDatabasePath(patientData.DATABASE_NAME);
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File file = new File(path, "patients.csv");
try
{
file.createNewFile();
CSVWriter csvWrite = new CSVWriter(new FileWriter(file));
...
}
....
}
Please let me know if any more info is needed from me!