I have a login page (username,password fields) that has a checkbox 'Remember me'. If the checkbox is selected, the application is required to remember the username & password for next login. That is done and working fine. However I am finding it hard to save the state of the checkbox field, i.e. whether it is checked or not. I am saving the username/password through the following code:
if (persistentObject.getContents() == null)
{
persistentHashtable = new Hashtable();
persistentObject.setContents(persistentHashtable);
} else {
persistentHashtable = (Hashtable) persistentObject.getContents();
}
if (persistentHashtable.containsKey("username") && persistentHashtable.containsKey("password"))
{
username.setText((String) persistentHashtable.get("username"));
passwd.setText((String) persistentHashtable.get("password"));
}
If the checkbox is selected and login is successfull, username and password are saved through the following:
if(checkBox1.getChecked() == true)
{
persistentHashtable.put("username", user_id);
persistentHashtable.put("password", password);
}
I tried to save the checkbox state with the line below but that is incorrect.
persistentHashtable.put("checkbox", checkBox1.setChecked(true));
Can somebody please help?