开发者

How to save spinner options?

开发者 https://www.devze.com 2023-03-29 05:29 出处:网络
This is probably a really easy question but Im extremely new to programming.. Could someone please explain to me how to save the answers (using a save button) chosen from several spinners in the SD c

This is probably a really easy question but Im extremely new to programming..

Could someone please explain to me how to save the answers (using a save button) chosen from several spinners in the SD card, I dont need a database or anything complicated like that. But then I also need a page to be able to see the answers.

So far my code just consists of 5 spinners and their options and thats it 开发者_如何学Go- code looks like this: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/Spinner1.html

Thank you so much!


You should check out SharedPreferences. http://developer.android.com/reference/android/content/SharedPreferences.html

//Saving
SharedPreferences prefs = getSharedPreferences("YourPreferencesName", 0);
prefs.edit().putString("KeyValue", actual_variable);
prefs.commit();

//Retrieving data
String str = prefs.getString("YourPreferencesName", "DefaultValueIfPrefNotFound");

Didn't check the syntax so it might contain errors.

0

精彩评论

暂无评论...
验证码 换一张
取 消