• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps What information to store in SharedPreference?

At the moment when creating an App I'm only using sqlite, and pulling data from their to display . I've seen shared preferences used a lot, but wondering what's the normal data to store with it?
 
Shared preferences are useful to store simple pieces of information, in the form of key/value pairs. Sometimes they are called 'properties'. Basically each preference has the format

prefkey = prefvalue

So you would look up the value for 'prefkey'. As you can see it's fairly limited, as there's only one value per key, but this is ideal for say, application settings (preferences). The main advantage of using shared preferences is simplicity, less code required to do it.

For more complex data requirements, where you need to store multiple pieces of information, then you'd use a database table. Although this does introduce more complexity in the implementation.
 
Back
Top Bottom