I adapted this tutorial (http://www.screaming-penguin.com/ node / 7749) to an Android application that I created to allow a button to click to export the current database to a user SD card. It works flawlessly.
But I'm afraid that users of my application will not be familiar with the db file, and I'm looking for a way to convert it to a more user-friendly format. I came across this topic (http://groups.google.com/group/android-beginners/browse_thread/thread/4e53ebca14daecfc), which recommends "request data from the database and write data to the csv file."
I was hoping someone could point me in the right direction to start figuring out how to do this. I find it difficult to find additional information about a particular method.
Or does it make sense to simply explain in a short โquestionโ how to read and access .db files?
thanks
EDIT: I also have a question about the sqlite export process, which I think I will just ask here and not create a new question. Is there a way to change the code below so that each export gets either a string representation of the date, or only one digit added to it? Right now, if you export a second time, it will automatically overwrite the old file. Thanks.
protected Boolean doInBackground(final String... args) { File dbFile = new File(Environment.getDataDirectory() + "/data/com.example.example/databases/data"); File exportDir = new File(Environment.getExternalStorageDirectory(), "exampledata"); if (exportDir.exists()) { exportDir.mkdirs(); } File file = new File(exportDir, dbFile.getName()); try { file.createNewFile(); this.copyFile(dbFile, file); return true; } catch(IOException e) { Log.e(MyApplication.APP_NAME, e.getMessage(), e); return false; } }
source share