I've got an app that allows the user to save the app SQLite database files to the SD card. This function has been in place for over a year and has worked just fine. I've had users email me their database files in cases where there was an error that I could not reproduce.
Recently, a user sent me his database files, and when I tried to load them into my app (by placing them into the app's database file location), the app crashed when trying to open the database file. This user has sent me his files before in the past with no problems.
The only differences between my app back then and now are: 1) I added app-2-SD functionality, and 2) My app targets 2.2 now versus 1.6 back then (but 1.5 is the min SDK version in both cases).
The user said he placed the app on the SD card and then the app started crashing. It doesn't even give him the option of submitting an error report.
When I placed his files in the emulator, I got the following stack trace:
11-09 22:32:04.275: ERROR/AndroidRuntime(757): Caused by: android.database.sqlite.SQLiteException: file is encrypted or is not a database
11-09 22:32:04.275: ERROR/AndroidRuntime(757): at android.database.sqlite.SQLiteDatabase.native_setLocale(Native Method)
11-09 22:32:04.275: ERROR/AndroidRuntime(757): at android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:1636)
11-09 22:32:04.275: ERROR/AndroidRuntime(757): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1586)
11-09 22:32:04.275: ERROR/AndroidRuntime(757): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:638)
11-09 22:32:04.275: ERROR/AndroidRuntime(757): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:168)
He's emailed me the data before, and the files had the correct database name and extension, so I'm giving him the benefit of the doubt and not assuming he sent an incorrect file. Has anyone seen this problem before, and know of any possible causes and/or solutions?
Update In case it makes any difference, I found out from the user that his phone is an HTC Evo 4G. I thought I read something somewhere about encrypted database files in more recent Android releases, where the database files are stored under /data/secure/... rather than /data/data/... I wonder if this could be related? In any case, after questioning the user further, I at least know that it is one specific table in the database file that is having a problem. Different parts of my app interact with different tables within the database file. The app works fine, and allows him to save/read data when he accesses the other tables, but when he accesses one particular table, just trying to open the file produces his error. I'm thinking I can add an ugly fix that catches this exception if it occurs and then drop the corrupted table and then recreate it. Thoughts?