getwritabledatabase

Concurrent access to a SQLite database in Android - db already closed

点点圈 提交于 2019-12-29 05:36:07
问题 I read a lot of topics on this subjet but no one could answer my question. I access my database from concurrent threads, my SQLiteOpenHelper implements the design pattern of the singleton so I have only one instance for my app. I access my database with code like this : SQLiteDatabase db = DatabaseHelper.getInstance().getWritableDatabase(); ... Do some update in the DB ... db.close(); I don't understand why I still get "db already closed" error, shouldn't the getWritableDatabase() method lock

Getting error while executing getwritabledatabase() in android

帅比萌擦擦* 提交于 2019-12-24 04:22:30
问题 I have created one class for database and multiple classes for tables and multiple activity classess everything works fine when I use the database class instance in activity class but at the same time when I use the database class instance in table class and run the application as soon as the control goes to getwritabledatabase I am getting exception and application is exited, below is the code for all 3 classes. Database class. public class Database extends SQLiteOpenHelper{ private static

Getting error while executing getwritabledatabase() in android

≯℡__Kan透↙ 提交于 2019-12-24 04:21:38
问题 I have created one class for database and multiple classes for tables and multiple activity classess everything works fine when I use the database class instance in activity class but at the same time when I use the database class instance in table class and run the application as soon as the control goes to getwritabledatabase I am getting exception and application is exited, below is the code for all 3 classes. Database class. public class Database extends SQLiteOpenHelper{ private static

NullPointerException on getWritableDatabase()

拥有回忆 提交于 2019-12-12 02:25:12
问题 i have a problem NullPointerException on getWritableDatabase() public class DatabaseTable extends Activity { private Context context; @Override public void onCreate(Bundle savedInstanceState) { LBD conection = LBD.get(this); super.onCreate(savedInstanceState); } } There is an implementation does not work "openHelper.getWritableDatabase()" public class LBD { private Context context; private static SQLiteDatabase db; private OpenHelper openHelper; public static LBD get(Context context) { LBD

SQLiteException: not an error

泄露秘密 提交于 2019-12-10 14:15:12
问题 In my app I'm using DB in many situations, but there is one situation in wich I'm getting an exception, not every time and could reproduce it (yet). This is happening only on OS versions 2.3.7 and 2.1-update-1. The code: public void removeOldOccurrences() { SQLiteDatabase db = dbHelper.getWritableDatabase(); Long oldTime = System.currentTimeMillis() - VALID_OCCURRENCE_TIME; String query = ""; try { query = "DELETE FROM " + LOCATIONS_TABLE + " WHERE not (" + REMEMBERED_FIELD + "=1) " + "and ("

Android getWritableDatabase() throws a NullPointerException

淺唱寂寞╮ 提交于 2019-12-06 15:57:59
问题 I am having trouble with my call to getWritableDatabase(). It is returning a NullPointerException. The thing that is strangest is that this error only began occurring after I commented out a couple lines of code in my android manifest. Now the project is back to where it was (I un-commented those sections and it still throws a NullPointerException). So I checked my context and tried this.getBaseContext() and this.getApplicationContext(). Using getApplicationContext() puts this out to logcat:

Android getWritableDatabase() throws a NullPointerException

时光总嘲笑我的痴心妄想 提交于 2019-12-04 18:20:45
I am having trouble with my call to getWritableDatabase(). It is returning a NullPointerException. The thing that is strangest is that this error only began occurring after I commented out a couple lines of code in my android manifest. Now the project is back to where it was (I un-commented those sections and it still throws a NullPointerException). So I checked my context and tried this.getBaseContext() and this.getApplicationContext(). Using getApplicationContext() puts this out to logcat: 08-12 09:24:20.042: E/AndroidRuntime(5572): FATAL EXCEPTION: main 08-12 09:24:20.042: E/AndroidRuntime

Concurrent access to a SQLite database in Android - db already closed

老子叫甜甜 提交于 2019-11-29 02:42:41
I read a lot of topics on this subjet but no one could answer my question. I access my database from concurrent threads, my SQLiteOpenHelper implements the design pattern of the singleton so I have only one instance for my app. I access my database with code like this : SQLiteDatabase db = DatabaseHelper.getInstance().getWritableDatabase(); ... Do some update in the DB ... db.close(); I don't understand why I still get "db already closed" error, shouldn't the getWritableDatabase() method lock the database until close() is called ? Other getWritableDatabase() calls from other threads should

Android NullPointerException + GetDatabaseLocked

旧城冷巷雨未停 提交于 2019-11-27 15:24:30
I have got a problem with my programm. I use a database to save the settings of my app. When I save the password in the app it´s all ok, but when I save the name of a "school class" with in principle the same method, but another table it crashes and I have got this error: 02-19 15:32:04.070: E/AndroidRuntime(14349): FATAL EXCEPTION: main 02-19 15:32:04.070: E/AndroidRuntime(14349): java.lang.NullPointerException 02-19 15:32:04.070: E/AndroidRuntime(14349): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224) 02-19 15:32:04.070: E/AndroidRuntime(14349): at

Android NullPointerException + GetDatabaseLocked

给你一囗甜甜゛ 提交于 2019-11-26 17:12:24
问题 I have got a problem with my programm. I use a database to save the settings of my app. When I save the password in the app it´s all ok, but when I save the name of a "school class" with in principle the same method, but another table it crashes and I have got this error: 02-19 15:32:04.070: E/AndroidRuntime(14349): FATAL EXCEPTION: main 02-19 15:32:04.070: E/AndroidRuntime(14349): java.lang.NullPointerException 02-19 15:32:04.070: E/AndroidRuntime(14349): at android.database.sqlite