0

I'm experimenting with a SQLite database to hold logging information from a messaging app.

I'm using SQLiteOpenHelper and forcing the db onto the SD card of an unrooted device using:

public LogDatabase(Context context, String dbname) {
  super(context, 
    Environment.getExternalStorageDirectory().getAbsolutePath() + 
      "/" + dbname, null, 3);
}

This appears to work fine: the database grows appropriately and the app doesn't throw any exceptions when writing to it.

The problem arises when I USB-mount the device and try to open the database from an external app (for example, sqlite3 from an Ubuntu command line). The error is always the same: "Error: file is encrypted or is not a database".

Is there something hinky about Android's treatment of SQLite? Or am I missing something fundamentally broken about the way I'm managing the db?

Edit: The original device in question is a HTC Desire S running v2.3.5.

Edit: I've re-run the test on an alternative device (Motorola ET1 running v2.3.4) and the problem does not occur. I can mount the device via Ubuntu and browse the database at will via the sqlite3 command line.

Wedgeski
  • 1
  • 4
  • It is possible to specify encryption on a SQLite database, however it's not enabled by default. Have you tried copying the database off the device to your PC, and then locally opening it using the cmd prompt? – Pete Aug 14 '12 at 16:36
  • @Pete - thanks for your reply, yes I've tried that with the same result. – Wedgeski Aug 15 '12 at 07:53

1 Answers1

0

Alright I appear to have found the answer. Once I suspected that it might be vendor-specific I found this Stack question:

Sqlite issues with HTC Desire HD

which suggested that HTC might have enabled write-ahead logging (WAL) on their devices.

Supposing that was true I pulled a very recent build of SQLite and built v3.7.14, which happily, can successfully open the problem database. This is as opposed to v3.6.22 of SQLite which could not.

Community
  • 1
  • 1
Wedgeski
  • 1
  • 4