I am trying to retrieve username from database table when i successfully login my application and show that on my home activity. I am trying to do this through cursor but i am not retrieving the column data. Any suggestions or help please.
Login function
public String loginUsers(String email,String pwd)
{
Cursor mCursor = database.rawQuery("SELECT * FROM " + DatabaseWrapper.FUNTUBE + " WHERE _email=? AND _password=?", new String[]{email,pwd});
if (mCursor != null) {
if(mCursor.getCount() > 0)
{
String name= mCursor.getString(mCursor.getColumnIndex("_username"));
mCursor.close();
return name;
}
}
return null;
}
Login.java
String user= FunTubeDBOperations.loginUsers(em, pwd);
if(true){
Toast.makeText(getApplicationContext(), "Login successfully!!", Toast.LENGTH_LONG).show();
Intent intent = new Intent(login.this, home.class);
intent.putExtra("name", user);
startActivity(intent);
finish();
}
Aucun commentaire:
Enregistrer un commentaire