| |
|
What are the different storage methods in Androids?
As all of us know every non-trival application will have to store data in one or another way. And data can be any of any forms like user settings, application settings, user data, images or some cache data. Below are several options to see persistent application data:-
(1)Shared Preferences
(2)Internal Storage
(3)External Storage
(4)SQLite Databases
(1)Shared Preferences:-We generally use this to save primitive data in key-value pairs. Here key must be a string and value can of one like Boolean, float, int long or can be of string. Internally it will stores data in XML file in private directory. An app can have multiple Shared Preferences files. Ideally, you will want to use Shared preferences to store application preferences.
(2)Internal Storage:-As we also know there are lots of situation where we want persist data but we also know there is limit on shared preferences. The Internal Storage data storage method is specifically for those situations where you need to store data to the device filesystem. And this data we not want to read by other app.
(3)External Storage:-app_private folder is located in the Android/data directory, and is also deleted when your app is uninstalled. To save (and/or read) files to the device’s external storage, your app must request for the WRITE_EXTERNAL_STORAGE permission. If you only want to read from the External Storage without writing, request for the READ_EXTERNAL_STORAGE permission. From Android 4.4, we can actually write to a “private” external storage folder without requesting WRITE_EXTERNAL_STORAGE.
(4)SQLite Databases:-Android provides support for apps to use SQLite databases for data storage. Databases created are app specific, and are available to any class within the app. | |
|
|
|
|