Android Question KeyValueStore problem with some devices

Arf

Well-Known Member
Licensed User
Longtime User
I use KeyValueStore to store some configuration values in my app, but I see I have received some ANR's recently, the Cause listed as follows:

Caused by: java.lang.RuntimeException: android.database.sqlite.SQLiteException: unable to open database file

Device: ALCATEL ONE TOUCH 4010X (Beetle_Lite_GSM)
Android: Android 2.3.3 - 2.3.7

Is there a minimum android version that KeyValueStore/Sql is to be used with?
 

Arf

Well-Known Member
Licensed User
Longtime User
thanks Erel.
I've pasted more of the ANR below (this is a slightly different ANR that I received this morning):
Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669)
at anywheresoftware.b4a.sql.SQL.Initialize(SQL.java:37)

Is there any way I can catch this exception and suppress any errors, and proceed without using the KeyValueStore functionality?
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Use a try catch block when trying to open the Database... if it errors out load defaults... KeyValueStore has a method to retrieve a value from a given key and if the value(or key?) is not present assume a default value
 
Upvote 0
Top