I am trying to get SQLite database to work on Android. Wrote a small test in the MainActivity that consists of entering values in 3 collumns of one row of the database. aft
Your context is null change Database db = new Database(context);
to Database db = new Database(this);
in onCreate
You should also change your Database constructor
so that you do not have to instantiate the SQLiteHelper
class every time you open the database.
public Database(Context c){
context = c;
sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null, MYDATABASE_VERSION);
}
And remove sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null, MYDATABASE_VERSION);
from your openToRead()
and openToWrite()