samedi 3 janvier 2015

how to get the information of the person who has logged in , in a new activity in android?

i have written a program to register a user with the help of name , contact , aadharno and security hint , so when i register a user the data gets saved inside my sqlite database and i have kept only aadharno as a username to login to my application , so whenever i enter the aadharno , i m successfully inside my application. Now , i have a new activity and i have a textview named aadharno , so whenever i click on login it takes me to this activity but my aadharno is not getting set inside my textview , please need some help.


My code for the above : the below code works fine when i register my aadharno and with the same aadharno i am able to login inside my application.



public String getSingleEntry(String aadhar) {
SQLiteDatabase sqLiteDatabase = dbHelper.getWritableDatabase();
Cursor cursor = sqLiteDatabase.query(Db_Governance.TABLE_NAME, null,
Db_Governance.AADHAR_NO + " =?", new String[] { aadhar }, null,
null, null);
if (cursor.getCount() < 1) // UserName Not Exist
{
cursor.close();
return "NOT EXIST";
}
cursor.moveToFirst();
String password = cursor.getString(cursor
.getColumnIndex(Db_Governance.AADHAR_NO));
cursor.close();
return password;
}


In My new acivity :



txtAadhaar = (TextView) findViewById(R.id.textAadhar1);
dbGovernance = new Database_Governance(getBaseContext());
dbGovernance.open(getBaseContext());

String user = txtAadhaar.getText().toString();
String password = dbGovernance.getSingleEntry(user);
if (user.equals(password)) {
txtAadhaar.setText(password);
} else {
Toast.makeText(getBaseContext(), "Aadhar No does not match",
Toast.LENGTH_LONG).show();
}


Whenever i enter my new activity , it shows the else part message.Please suggest what changes do i have to make. Thanking you in advance


Aucun commentaire:

Enregistrer un commentaire