Search code examples
androidsqlitejournal

Android SQLite database and journal permissions


I have an android application on android market, this application created with sqlite database with world readable and writable mode. SQLite database doesn't store any user specific information. However in rooted handsets if i open /data/data/packagename/databases/ i can see those files as world readable/writable, pretty much for all the applications.

Now i have changed application SQLite database to private mode, after that database file permission changed to non-world readable/writable. However "database-journal" file permission didn't change.

Is this an android issue, any time application upgrades database journal permissions doesn't change even main database created with private mode.

Do i need to worry about journal file permissions, this journal file most of the time it's empty file.Any suggestions to fix the above issue..?


Solution

  • If you create a database MODE_WORLD_WRITEABLE then every app on your device can delete it, open it and insert / read data, copy it, etc even if that app does not have the WRITE_EXTERNAL_STORAGE permission.

    The journal is created by sqlite, there is no reason for sqlite to change the permissions of the file once it exists. Deleting the database file probably does not delete the journal as well which might be the reason for your problem.

    If you delete the journal file before opening the db or chmod / File.setWritable() it to your needs the issue should be fixed.