开发者

How to store data in temporary memory

开发者 https://www.devze.com 2023-02-26 04:31 出处:网络
I want the way or the code e.g. to store the value of EditText in the temp开发者_运维知识库 variable so when I redirect the activity at that time it stores the value in the temporary variable. When I

I want the way or the code e.g. to store the value of EditText in the temp开发者_运维知识库 variable so when I redirect the activity at that time it stores the value in the temporary variable. When I move back to the activity I can store back it to the EditText.


SharedPreferences may be the easiest way in your case. This is designed for storing a relatively-small amount of data (ballpark practical maximum around 50-100 values) in classic key/value format.

http://androidandandroid.wordpress.com/2010/07/25/android-tutorial-16/

http://developer.android.com/reference/android/content/SharedPreferences.html


Please check this thread you want the same thing. How to configure application settings in android?


You could use SharedPreferences.

import android.content.SharedPreferences;

...

private SharedPreferences mPrefs;

private static final String MY_TEXT_BOX_STRING_KEY = "prefs_textbox_key"

...

mPrefs = getSharedPreferences("myAppPrefs",0);

...

// Get the string:

myTextBoxString = prefsGetString(MY_TEXT_BOX_STRING_KEY);

// Set the string:

prefsSetString(MY_TEXT_BOX_STRING_KEY, "blahblah");
0

精彩评论

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