I have an application in which
1:user sign Up her ID and password,
2: then on 2nd screen he sign In.
3 After successful log in user navigate to the screen from where he can change his password
Problem statement: I want that when user clicks on Change password button then he navigates to signup screen and here in User Name edit text he could see his name and there he may change his Password Any solution will be appreciated.
DB:
public class LoginDataBaseAdapter {
static final String DATABASE_NAME="login.db";
static final int DATABASE_VERSION=1;
public static final int NAME_COLUMN=1;
static final String DATABASE_CREATE= "CREATE TABLE " + " LOGIN " + "(" + " ID " + " INTEGER PRIMARY KEY AUTOINCREMENT," + " USERNAME text,PASSWORD text);";
public SQLiteDatabase db;
private final Context context;
private DataBaseHelper dbHelper;
public LoginDataBaseAdapter(Context _context)
{
context=_context;
dbHelper=new DataBaseHelper(context,DATABASE_NAME,null,DATABASE_VERSION);
}
public LoginDataBaseAdapter open()throws SQLException
{
db=dbHelper.getWritableDatabase();
return this;
}
public void close()
{
db.close();
}
public SQLiteDatabase getDatabaseInstance()
{
return db;
}
public void insertEntry(String userName,String password)
{
ContentValues newValues=new ContentValues();
newValues.put("USERNAME", userName);
newValues.put("PASSWORD", password);
db.insert("LOGIN", null, newValues);
Toast.makeText(context,"Successfully created", Toast.LENGTH_LONG).show();
}
public int deleteEntry(String UserName)
{
String id=String.valueOf(id);
String where="USERNAME ?";
int numberOFEnteriesDeleted=db.delete("LOGIN",where,new String[]{UserName});
Toast.makeText(context," Deleted Successfully:"+numberOFEnteriesDeleted, Toast.LENGTH_LONG).show();
return numberOFEnteriesDeleted;
}
public String getSingleEntry(String userName)
{
Cursor cursor=db.query("LOGIN",null, "USERNAME=?",new String[]{userName}, null, null,null);
if (cursor.getCount()<1)
{
cursor.close();
return "NOTEXIST";
}
cursor.moveToFirst();
String password =cursor.getString(cursor.getColumnIndex("PASSWORD"));
cursor.close();
return password;
}
public void updateEntry(String userName,String password)
{
ContentValues updateValues=new ContentValues();
updateValues.put("USERNAME", userName);
updateValues.put("PASSWORD", password);
String where="USERNAME=?";
db.update("LOGIN", updateValues, where, new String[]{userName});
}
}
On my Main Activity i want to retrive the USER Name