dimanche 19 avril 2015

Second SQLite issue, login to my application

I have encountered my second issue when using SQLite to create a login/register activity for my app. I am following an online tutorial, I think I understand it all and I have followed what he did exactly, it worked for him, but my application crashes. Here is the function within my database:

public Cursor getInformation(DatabaseOperations dop){
SQLiteDatabase SQ = dop.getReadableDatabase();
String[] columns = {TableData.TableInfo.USER_NAME, TableData.TableInfo.USER_PASS, TableData.TableInfo.USER_EMAIL};
Cursor CR = SQ.query(TableData.TableInfo.TABLE_NAME, columns, null, null, null, null, null);
return CR;

The issue occurs once I have clicked the login here is the code for the button:

public void SignInOnClick(View view){
Bundle b = getIntent().getExtras();
int status = b.getInt("status");
if(status == 1){
Toast.makeText(getBaseContext(),"Please wait...",Toast.LENGTH_LONG).show();
email = Email.getText().toString();
password = Password.getText().toString();
DatabaseOperations DOP = new DatabaseOperations(CTX);
Cursor CR = DOP.getInformation(DOP);
boolean loginstatus = false;
String NAME = "";
if(email.equals(CR.getString(2)) && (password.equals(CR.getString(1))))
loginstatus = true;
NAME = CR.getString(0);
Toast.makeText(getBaseContext(),"Login Successful \n Welcome"+NAME, Toast.LENGTH_LONG).show();
Toast.makeText(getBaseContext(), "Login Failed", Toast.LENGTH_LONG).show();

The error reads as the following according to logcat:

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.os.Bundle.getInt(java.lang.String)' on a null object reference

Aucun commentaire:

Enregistrer un commentaire