Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - database disk image is malformed

In my android app I am getting "database disk image is malformed" What are the reasons for getting this error?

not closed db? multiple threads accessing the db? or android just got corrupted?

Thanks

android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed
   android.database.sqlite.SQLiteQuery.native_fill_window(Native Method)
   android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:75)
   android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:288)
   android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:269)
   android.database.AbstractCursor.moveToPosition(AbstractCursor.java:171)
   android.database.AbstractCursor.moveToFirst(AbstractCursor.java:248)
...
like image 542
Daniel Benedykt Avatar asked Jun 02 '10 17:06

Daniel Benedykt


People also ask

How do I fix database disk image is malformed?

You may see the "database disk image is malformed" error in TekRADIUS log. This could happen during unplanned shutdown or reboot. The error indicates that one or more of the sqlite3 databases may have become corrupted. You need to have sqlite3.exe to diagnose and fix the problem.

How do I fix SQLite database disk image is malformed?

If you find the 'SQLite Database Disk Image is malformed' error, export your database into an SQL file. To export the data, click the File tab followed by Export>>Database to SQL file. The Export SQL dialog box appears on the screen; select the objects you want to export and define the other options.


1 Answers

I've come across many instances of people reporting sqlite corruption issues on Android. The majority of times it's related to a task killer but there is still a small margin of people still experiencing random SQLite corruption.

For example, this issue: http://code.google.com/p/android/issues/detail?id=4866

JRL's links above are also very useful for understanding what types of events can lead to a corrupted SQLite DB image.

Also, SQLite itself has been patched in recent history to resolve various (rare) data corruption scenarios. See http://www.sqlite.org/changes.html. So the version of SQLite that ships with Android isn't the latest, but as Android evolves, so do the apps that are bundled with it, such as SQLite.

At the end of the day, there's only so much we can do as programmers to safeguard against SQLite corruption so its sometimes advantageous to code safety mechanisms into our apps, such as periodic DB backups to SDCard (that's what I do).

like image 58
Brad Hein Avatar answered Oct 02 '22 20:10

Brad Hein