0

恢复代码:

final SharedPreferences settings = getSharedPreferences("pref", 0);
        settings.getString("user", "");
        settings.getString("pw", "");

店铺代码:

SharedPreferences.Editor editor = settings.edit();
                      editor.putString("user", etuser.getText().toString());
                      editor.putString("pw", etpw.getText().toString());
                      editor.commit();

此代码不起作用,并且没有发生错误

4

2 回答 2

2
    String s1 = settings.getString("user", "");
    String s2 = settings.getString("pw", "");

我的意思是 - 您返回了所需的字符串,但您没有将其值分配给任何东西。

于 2010-12-27T12:49:04.830 回答
0
editor.putString("user", etuser.getText().toString());

editor.putString("pw", etpw.getText().toString());

顺便说一句,您不需要toString().

于 2012-08-19T23:21:37.643 回答