Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Android Data Persistence Key-Value Saving with SharedPreferences Adding a Storage Preference

Evan Dix
Evan Dix
1,641 Points

Will my saved shared prefs be there even after the app is closed?

I am saving a string in my shared prefs. Lets say the user closes the app and opens another app. Then they go back to the shared prefs app. With the string they committed to the shared prefs still be there??

1 Answer

Hey Evan Dix,

There are a few ways to persist data in Android. The SharedPreferences class is one of those ways!

Once you use commit() to save your data, you can retrieve it after your app has been closed, your process has been killed (by the user or the system), or the user powers off his/her device.

I recommend that you read this doc, specifically under the Shared Preferences header.

http://developer.android.com/guide/topics/data/data-storage.html

Keep coding!