I've the following code, it gives a run time error as below. Why?
try{
String myPath = DB_PATH + DB_NAME;
mDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
}catch(SQLiteException e){}
Runtime Error:
:sqlite returned: error code = 1, msg = no such table: android_metadata
:SELECT locale FROM android_metadata failed
:Failed to setLocale() when constructing, closing the database
:android.database.sqlite.SQLiteException: no such table: android_metadata
The current version of SQLite handles multiple connections through its thread-mode options: single-thread, multi-thread, and serialized. Single-thread is the original SQLite processing mode, handling one transaction at a time, either a read or a write from one and only one connection.
The SQLITE_TOOBIG error results when SQLite encounters a string or BLOB that exceeds the compile-time or run-time limit. The SQLITE_TOOBIG error code can also result when an oversized SQL statement is passed into one of the sqlite3_prepare_v2() interfaces.
Make sure the table name android_metadata
is there, with a column name locale
, you could insert en_US as value for locale
.
Or rather execute this sql statement:
CREATE TABLE "android_metadata" ("locale" TEXT DEFAULT 'en_US');
Edit: If you call openDatabase() with SQLiteDatabase.NO_LOCALIZED_COLLATORS flag, you would not need to have this table, else you will need to have this table around.
See setLocale().
When open read only db and its not already created, use NO_LOCALIZED_COLLATORS.
try{
String myPath = DB_PATH + DB_NAME;
mDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY+ SQLiteDatabase.NO_LOCALIZED_COLLATORS);
}catch(SQLiteException e){}
android_metadata table will be created if you open the database with write permissions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With