2012-05-29 29 views
3

在我的應用程序中,我將數據保存在SharedPreferences上。在android phonegap上獲得SharedPreference值

這裏是我的代碼

public void initUserData(Context context, String pKey1, String pKey2, long id) { 
     SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); 

     prefs.edit().putString("key1", pKey1).commit(); 
     prefs.edit().putString("key2", pKey2).commit(); 
     prefs.edit().putLong("user.id", id).commit(); 
    } 

怎麼能使用PhoneGap的,我得到SharedPreferences值?我的意思是使用JavaScript獲取數據

回答

2

手機間隙本身支持共享首選項,不需要使用android編碼。請參閱docs.phonegap.com

+0

據我所知phonegap確實支持w3c而不是sharedpreferences, – Muatik