I have this code in the main Activity, where fetchxml is an AsyncTask:
String GroupID = PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getString("GroupID","");
fetchxml.execute(GroupID);
and in the doInBackground(String... paras), it is:
protected String doInBackground(String... paras) {
Log.d("URL+ paras[0]", paras[0]);
String xml = parser.getXmlFromUrl(URL+ paras[0]);
return xml;
}
Why I didn’t get any value in paras[0]?
When the value is null or it’s empty String then Log.d won’t show the tag either. Make sure that sharedPreferences returns a value. It seems that the key ‘GroupID’ doesn’t exist and sharedPreferences returns default value which is an empty String “”