Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid database corrupt, but can open in SQLite Manager. Recoverable?
    primarykey
    data
    text
    <p>In the latest two weeks, without releasing an update to my app, I have started getting a bunch of reports with corrupted databases. Below is the stacktrace. Android cannot open the database, and neither could the sqlite-manager program on my computer. However, the SQLite manager-addon to firefox could open it. After running the command "compact database", the database was fixed and I could open it in android. Is there any way I could do something like this within my app? The big problem is that I cannot even attempt to open the database, because newer versions of Android will immediately delete and replace the database, as you can see in the stacktrace below. Can PRAGMA Statements somehow be executed without opening the database?</p> <p>Regards,</p> <pre><code>02-22 09:55:20.245: ERROR/Database(5382): CREATE TABLE android_metadata failed 02-22 09:55:20.245: ERROR/Database(5382): Failed to setLocale() when constructing, closing the database 02-22 09:55:20.245: ERROR/Database(5382): android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed 02-22 09:55:20.245: ERROR/Database(5382): at android.database.sqlite.SQLiteDatabase.native_setLocale(Native Method) 02-22 09:55:20.245: ERROR/Database(5382): at android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:1950) 02-22 09:55:20.245: ERROR/Database(5382): at android.database.sqlite.SQLiteDatabase.&lt;init&gt;(SQLiteDatabase.java:1818) 02-22 09:55:20.245: ERROR/Database(5382): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:817) 02-22 09:55:20.245: ERROR/Database(5382): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:851) 02-22 09:55:20.245: ERROR/Database(5382): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:844) 02-22 09:55:20.245: ERROR/Database(5382): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:540) 02-22 09:55:20.245: ERROR/Database(5382): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203) 02-22 09:55:20.245: ERROR/Database(5382): Deleting and re-creating corrupt database /mnt/sdcard/myapp/backup.sqlite 02-22 09:55:20.245: ERROR/Database(5382): android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed 02-22 09:55:20.245: ERROR/Database(5382): at android.database.sqlite.SQLiteDatabase.native_setLocale(Native Method) 02-22 09:55:20.245: ERROR/Database(5382): at android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:1950) 02-22 09:55:20.245: ERROR/Database(5382): at android.database.sqlite.SQLiteDatabase.&lt;init&gt;(SQLiteDatabase.java:1818) 02-22 09:55:20.245: ERROR/Database(5382): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:817) 02-22 09:55:20.245: ERROR/Database(5382): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:851) 02-22 09:55:20.245: ERROR/Database(5382): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:844) 02-22 09:55:20.245: ERROR/Database(5382): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:540) 02-22 09:55:20.245: ERROR/Database(5382): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203) </code></pre> <p>Edit: I manager to open the database like this:</p> <pre><code>db = SQLiteDatabase.openDatabase(database, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS); </code></pre> <p>But when I run this:</p> <pre><code>String sqlQuery = "pragma integrity_check"; db.execSQL(sqlQuery); </code></pre> <p>I get this:</p> <pre><code>ERROR/AndroidRuntime(9144): Caused by: android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed: pragma integrity_check </code></pre> <p>Edit2: I have realized that vacuuming the database fixes the issue. But if I vacuum from inside my app, with exeSQL("vacuum"), it does not help. Why is this? :'(</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload