简体   繁体   中英

How to achieve NSUserDefaults concept in Android

In iPhone we are using NSUserDefaults to temporarily store the data (around 30 images and texts) for a custom list view. How can we achieve this in Android?

By using sharedpreferences concept u can achieve this.

see this link: SharedPreferences

and refer this example: example for shared preferences

文本的SharedPreferences但30张图片我建议使用SD卡中的文件夹

SharedPreferences userPreference = getSharedPreferences("preference name", MODE_PRIVATE);

Use the concept of SharedPreferences. This will contain the prefs. of the user similar to that of NSUserDefaults. Something like this :

SharedPreferences sharedPreference = getSharedPreferences("Sample Preference", MODE_PRIVATE);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM