problem calling setLocale when creating a new db in android
i'm trying some db access code for the first time and i'm getting some errors and would appreciate some help. this is what is happening:
1) i'm creating a new instance of SQLiteOpenHelper by calling this constructor:
public MyDbOpenHelper(Context context) {
super(context, "some_name.db", null, 1);
}
the above instance is the variable myHelper used below
2) i'm calling myHelper.getReadableDatabase()
3) at this point Android calls my onCreate method. my implementation of this method begins as follows:
public void onCreate(SQLiteDatabase db) {
db.setLocale(new Locale("en"));
//...
}
4) the above call does not complete. i get the following dump:
BEGIN TRANSACTION failed setting locale
couldn't open some_name.db for writing (will try read-only): android.database.sqlite.SQLiteException: cannot start a transaction within a transaction at android.database.sqlite.SQLiteDatabase.native_setLocale(Native Method) at android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:1751) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper... at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper....it looks like since i'm trying to get a readable db when the 开发者_如何学编程db does not yet exist, so Android tries to create it and creates a writable db for the setLocale... and is that why it complains about "transaction within transaction"? how is it supposed to be done?
thanks, any help would be appreciated
精彩评论