2011-05-09 43 views

回答

4

向用戶(在創建用戶時)註冊後保存細節...

// Get the app's shared preferences 
SharedPreferences login_app_preferences = context.getSharedPreferences("LOGIN_DETAILS", MODE_PRIVATE); 

// Update fields 
SharedPreferences.Editor editor = login_app_preferences.edit(); 
editor.putString("email", strEmailOrLoginId); 
editor.putString("password", strPassword); 
editor.commit(); // Very important 

要訪問它在應用程序的任何地方....

// Get the app's shared preferences 
SharedPreferences login_app_preferences = context.getSharedPreferences("LOGIN_DETAILS", MODE_PRIVATE); 

strUserName = login_app_preferences.getString("email", ""); 
strPassword = login_app_preferences.getString("password", "");