Android provides several options for you to save persistent application data. The solution you choose depends on your specific needs: private/public, small/large datasets.
Your data storage options are the following:
Shared Preferences: Store private primitive data in key-value pairs.
Internal Storage: Store private data on the device memory.
External Storage: Store public data on the shared external storage.
SQLite Databases: Store structured data in a private database.
Network Connection: Store data on the web with your own network server.
Content Provider: Shared repository globally shared by all apps.
Preferences is an Android lightweight mechanism to store and retrieve <key-value> pairs of primitive data types (also called Maps, and Associative Arrays. PREFERENCES are typically used to keep state information and shared data among several activities of an application. In each entry of the form <key-value> the key is a stringand the value must be a primitive data type. Preferences are similar to Bundles however they are persistent while Bundles are not.
Using Preferences API calls:
You have three API choices to pick a Preference:
1.getPreferences() from within your Activity, to access activity specific preferences
2.getSharedPreferences() from within your Activity to access application-level preferences
3.getDefaultSharedPreferences(), on PreferencesManager, to get the shared preferences that work in concert with Android's overall preference framework
Your data storage options are the following:
Shared Preferences: Store private primitive data in key-value pairs.
Internal Storage: Store private data on the device memory.
External Storage: Store public data on the shared external storage.
SQLite Databases: Store structured data in a private database.
Network Connection: Store data on the web with your own network server.
Content Provider: Shared repository globally shared by all apps.
Preferences is an Android lightweight mechanism to store and retrieve <key-value> pairs of primitive data types (also called Maps, and Associative Arrays. PREFERENCES are typically used to keep state information and shared data among several activities of an application. In each entry of the form <key-value> the key is a stringand the value must be a primitive data type. Preferences are similar to Bundles however they are persistent while Bundles are not.
Using Preferences API calls:
You have three API choices to pick a Preference:
1.getPreferences() from within your Activity, to access activity specific preferences
2.getSharedPreferences() from within your Activity to access application-level preferences
3.getDefaultSharedPreferences(), on PreferencesManager, to get the shared preferences that work in concert with Android's overall preference framework
Download Sample code: Here
No comments:
Post a Comment