2011-02-04 93 views
1

我使用共享首選項來存儲密碼,但是當我的應用程序再次啓動它時詢問首選值.i想要一旦我輸入了首選密碼,它應該被修復它應該再次問我。在android中使用共享首選項存儲密碼

+5

請顯示您的代碼。沒有它,很難說出什麼問題。 – 2011-02-04 08:35:23

回答

8

如果你想保存下面的代碼密碼的使用 -

Editor editor = getSharedPreferences("password", 0).edit(); 
    editor.putString("password", "your password"); 
    editor.commit(); 

而且你喜歡的地方把它找回來把下面的代碼有 -

SharedPreferences pref = getSharedPreferences("password", 1); 
    String password = pref.getString("password", ""); 

如果還是它不工作,把你的代碼在這裏。