Questions tagged [getwritabledatabase]

getWritableDatabase is one of the methods of the Android's SQLiteOpenHelper class which returns a reference to a SQLiteDatabase.

The getWritableDatabase is a method of the SQLiteOpenHelper class, from the Android platform, used to retrieve a reference to a SQLiteDatabase in which the user can insert data. Calling this method will either open an already created database or will trigger the creation of the database if one doesn't exist. Executing this method may take a long time so it's recommended to not call it on the main UI thread.

32 questions
1
vote
2 answers

"Java.lang.NullPointerException" exception in getWritableDatabase method

I am trying to build a small application that store some information in a SQLite table. But I always receive a "Java.lang.NullPointerException" exception in getWritableDatabase method. Can anyone help me? All the code is below. Manifest:
0
votes
1 answer

Difference between getWritableDatabase() and database.execSQL("INSERT INTO table (column name) values(value));

I noticed two methods for insert data into database tables. Example: getWritableDatabase() method and database.execSQL("INSERT INTO table (column name) values(value)). What is the difference between these two methods? Which one is best?
0
votes
0 answers

Android Sqlite always null even after calling getWritableDatabase()

Good morning stackoverflow lovers :) i wrote my Sqlite class , but there is an error "Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.database.sqlite.SQLiteDatabase.execSQL(java.lang.String)' on a null…
0
votes
1 answer

Android Studio - SQLite Database (getWritableDatabase function) doesn't work after a copy of the project

My project was working before I copied the directory from my old computer to my new one. Here is my logcat: 06-15 22:28:03.169 3205-3205/com.example.moric.pronostic W/System: ClassLoader referenced unknown path:…
Moric
  • 1
  • 1
0
votes
1 answer

Cannot write to sqlite from another activity

I try to call a method and write to my database from another activity in android but my app crashes because it cannot write. My activity does not have On Create because it does not need it. Therefore I have this code: DB db = new…
We're All Mad Here
  • 1,544
  • 3
  • 18
  • 46
0
votes
3 answers

Error in changing database to getWritableDatabase() method

I have source code that use the database. My database codes are in a class and when I insert anything from this class there is no problem. But if the method call in the other class the error message " java.lang.nullpointerexception " will be shown…
0
votes
2 answers

SQLite - getDatabase called recursively

Here is my code: public class DBHelper extends SQLiteOpenHelper { @Override public void onCreate(SQLiteDatabase db) { db.execSQL("sql-query"); try { //db = getWritableDatabase(); fillAllDB(db); }…
Mark Korzhov
  • 2,109
  • 11
  • 31
  • 63
0
votes
1 answer

Sqlite Nullpointer Exception in getWritableDatabase

i want to create my sqlite database but i always receive a nullpointer exception. I start my Databasehelper this way: ContentProvider cp = new ContentProvider(this, this); Then public ContentProvider(Context _context, MainActivity activity) { …
0
votes
2 answers

Opening SQLite database (in inner database adapter) crashes an Android App

I have database problem in my Android app that I can't seem to figure out. I do not see any errors in my code but when I run the application, the app crashes with LogCat pointing to multiple points in my code. Among these are: NullPointerExceptions…
Dut A.
  • 1,029
  • 11
  • 22
0
votes
2 answers

NullPointerException when use DatabaseHelper second times

I want to update data and show in the fragment list, the data is already pass into db, but it got NullPointerException when use getWritableDatabase() to update, Now I know it can't called getWritableDatabase() and getReadableDatabase() again, and no…
Sarah0050
  • 135
  • 1
  • 1
  • 9
0
votes
1 answer

getWriteableDatabase() throws Null Pointer Exception

I'm getting a crash when trying to open an SQLiteDatabase I have for writing with a Null Pointer Exception. Here's how I instantiate the SQLiteOpenHelper: private final OpenHelper mOpenHelper; public static DataManager getInstance() { if…
mpellegr
  • 3,072
  • 3
  • 22
  • 36
0
votes
1 answer

SQLiteAssetHelper and getWritableDatabase

I'm having have some trouble with my Database activity. I am unable to write to the database and view the database using the following code. my Database activity: package com.jacob.eindproject; import android.content.ContentValues; import…
user3104217
  • 73
  • 1
  • 1
  • 6
0
votes
2 answers

NullPointerException on getWritableDatabase()

i have a problem NullPointerException on getWritableDatabase() public class DatabaseTable extends Activity { private Context context; @Override public void onCreate(Bundle savedInstanceState) { LBD…
Max Usanin
  • 2,479
  • 6
  • 40
  • 70
0
votes
2 answers

Android database leak found

When i enter another activity to insert new item into the database,return and then go in that activity it gives me an error: 04-03 18:53:26.914: E/Database(18134): Leak found 04-03 18:53:26.914: E/Database(18134): java.lang.IllegalStateException:…
Worker123
  • 595
  • 4
  • 13
  • 32
-1
votes
1 answer

SQLiteDatabase dbm = this.getWritableDatabase(); recursive

Help! I'm transferring geolocation data from android to the database. Gives an error message. Error: (45, 46) error: can not find symbol method getWritableDatabase (). Help! enter image description here public class AndroidGPSTrackingActivity…
Alex Nikonov
  • 1
  • 1
  • 3