External SQLite File content accessing error
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: 开发者_JAVA百科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
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.
call openDatabase() with SQLiteDatabase.NO_LOCALIZED_COLLATORS flag,this is what i did when i met the problem last time...
精彩评论