Android Sqlitedatabase Nullpointerexception
Okay full code now: DBOpenHelper: public class DBOpenHelper extends SQLiteOpenHelper {   private SQLiteDatabase mDatabase;  private static final int DATABASE_VERSION = 1;  private
Solution 1:
As I see you didn't initialize your database :
privatestaticDBOpenHelperdbHelper=newDBOpenHelper(context);
publicstaticSQLiteDatabasedb= dbHelper.getWritableDatabase();
You need to have a constructor in your DBOpenHelper class where you can set the name of database for your project.You are setting your database in your DB class,but never using it :
privatestaticStringfilename="RTDB.sql";
That's why you are getting NullPointerException, because there is no database which you can get.
EDIT : You can do something like this :
publicDBOpenHelper(Context context, String databaseName) {
    super(context,  databaseName, null, DATABASE_VERSION);
}
in that way when you are initializing your database you can set the name of database that you want to use.
Solution 2:
static Context context;
privatestaticDBOpenHelperdbHelper=newDBOpenHelper(context, "RTDB.sql");
i guess context == null.
Post a Comment for "Android Sqlitedatabase Nullpointerexception"