我想通過SharedPreferences偏好設置,作爲AsyncTask中doInBackground函數的參數。我已經傳遞了一個字符串(url),所以我需要將prefs也作爲字符串傳遞。我可以簡單地使用prefs.toString()將其轉換爲字符串嗎?將SharedPreferences傳遞給doInBackground()
這是我設置首選項:
if (prefs.getBoolean("firstrun", true)) {
prefString = prefs.toString();
prefs.edit().putBoolean("firstrun", false).commit();
}
當您嘗試使用「prefs.toString() 「將其轉換爲字符串,會發生什麼? –
爲什麼不參考背景中的前綴? –
我不知道該怎麼做! – defiant