Hi guys,
I am using the following code to set the input from an EditView in a
SharePreference.
But I am also trying to read the input back into the EditView.
final EditText input_nickname = (EditText)
findViewById(R.id.EditText_Nickname);
input_nickname.setOnKeyListener( new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode,
KeyEvent event) {
// TODO Auto-generated method stub
if(
mGameSettings.contains(GAME_PREFERENCES_NICKNAME) ){
Toast.makeText(QuizSettingsActivity.this, "Exists",
Toast.LENGTH_SHORT ).show();
input_nickname.setText( mGameSettings.getString(GAME_PREFERENCES_NICKNAME,
"") );
}else{
String processed_nickname
= input_nickname.getText().toString();
Toast.makeText(QuizSettingsActivity.this, "Not Exists",
Toast.LENGTH_SHORT ).show();
Editor editor =
mGameSettings.edit();
editor.putString(GAME_PREFERENCES_NICKNAME, processed_nickname);
editor.commit();
}
return false;
}
});
The problem is, when I revisit the activity, the EditView never
contains the text I input the last time. I actually contains the above
TextView content and I can't then edit it.
I know that's not really clear but does anyone have any ideas to help
with seting and retrieving shared preferences properly ??
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en