I'm working with sharedpreferences and I can put names in the .xml file, the problem is when I try to get only the first name name ins this case I can see: D/mySharedPref: [alan, lyneth, daniel, oscar] but I want to see only alan how can I get the name that I'm asking
String id = "1";
for(int i = 0; i<getListValueFromKey.size(); i++){
Log.d("mySharedPref", ""+getListValueFromKey);
//in the log window show this:
// D/mySharedPref: [alan, lyneth, daniel, oscar]
}
Okay, this is the way I resolved the problem:
//add to an Array
Object[] resourceArray = getListValueFromKey.toArray();
//I preferred to leave this var outside to manipulate after
int i;
//I put in the log the first name
Log.d("myName", ""+resourceArray[1]);
//I log the names inside the array
for(i = 0; i<resourceArray.length; i++){
Log.d("mySharedPref", ""+resourceArray[i]);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.