External SQLite Error accessing file contents

I have the following code, it gives a runtime error as shown 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 
+6
android sqlite
source share
3 answers

Make sure there is a table name android_metadata , with the column name locale , you can insert the value en_US as the value for locale .

Or rather, execute this sql statement:

 CREATE TABLE "android_metadata" ("locale" TEXT DEFAULT 'en_US'); 

Edit: if you call openDatabase () with the SQLiteDatabase.NO_LOCALIZED_COLLATORS flag, you will not need to have this table, otherwise you will need to have this table.

See setLocale () .

+24
source share

When only reading db is open and not yet 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){} 

The android_metadata table will be created if you open the database with write permissions.

+8
source share

call openDatabase () with the SQLiteDatabase.NO_LOCALIZED_COLLATORS flag, this is what I did when I met the problem for the last time ...

+5
source share

All Articles