Trying to access pieces of information in my database, depending on whether the email address matches, however I keep getting the error message:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.wolfe_000.final_final_zeno/com.example.wolfe_000.final_final_zeno.Main}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.sqlite.SQLiteDatabase android.content.Context.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase$CursorFactory, android.database.DatabaseErrorHandler)' on a null object reference
Here is the function that is causing the problem:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Name = (TextView) findViewById(R.id.Username);
Weight = (TextView) findViewById(R.id.textView11);
Goal = (TextView) findViewById(R.id.textView26);
img = (ImageView) findViewById(R.id.ProPic);
DatabaseOperations DOP = new DatabaseOperations(CTX);
Cursor CR = DOP.getInformation(DOP);
CR.moveToFirst();
do
{
if(EMAIL.equals(CR.getString(2)))
{
NAME = CR.getString(0);
WEIGHT = CR.getInt(3);
GOAL = CR.getInt(4);
}
}while(CR.moveToNext());
Name.setText(NAME);
Weight.setText(Integer.toString(WEIGHT));
Goal.setText(Integer.toString(WEIGHT-GOAL));
}
Aucun commentaire:
Enregistrer un commentaire