Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

External SQLite File content accessing error

Tags:

android

sqlite

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
like image 555
vnshetty Avatar asked Mar 04 '11 07:03

vnshetty


People also ask

Can SQLite handle multiple connections?

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.

What is SQLite error?

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.


2 Answers

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().

like image 76
SteD Avatar answered Oct 13 '22 00:10

SteD


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.

like image 31
Daniel Magnusson Avatar answered Oct 13 '22 00:10

Daniel Magnusson