I am using public class DatabaseHandler that extends SQLiteOpenHelper and this is my method to get all the data from the db, it looks all fine but crashes, and activity says nullpointerException. Is there anything to change in the code? I have only one row of information..
// Getting all data
public Cursor getData(String UserName, String Email, String Password,
String BirthDate, String PinCode, String Country, String PaypalID,
String mobile, String FBID) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_DATA, new String[] { "UserName",
"Email", "Password", "BirthDate", "PinCode", "Country",
"PaypalID", "mNUMBER", "FBID" }, null, null, null, null, null,
null);
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
Log.i("counttttttttttttt", "" + cursor.getCount());
UserName = cursor.getString(0);
Email = cursor.getString(1);
Password = cursor.getString(2);
BirthDate = cursor.getString(3);
PinCode = cursor.getString(4);
Country = cursor.getString(5);
PaypalID = cursor.getString(6);
mobile = cursor.getString(7);
FBID = cursor.getString(8);
} while (cursor.moveToNext());
}
}
db.close();
return cursor;
}
In, Account Activity,
db = new DatabaseHandler(AccountActivity.this);
// Declared all String
db.getData(name, email, password, birthdate, pincode, country, paypal,
mobile, fbid);
and set those String to TextView as required..
but it says nullpointer exception.