Most android apps require saving information between client sessions. We would want to save each type of data according to its purpose and when we’re going to use it. Android platform provides several methods to handle your data and persisting it.
- Shared Preferences – saving key-value pairs of primitive types. This data will persist across user sessions (even if your application is killed).
- Internal Storage – storing private data on the device memory. This data will be saved inside private files on the device internal memory. Other apps can not read those files and neither the user. When uninstalling the app, those files are automatically removed.
- External Storage – saving data inside files on an external storage such as SD card. This data is public and available to everyone. Also, this data can become unavailable if the user mounts the external storage or removes the media.
- SQLite Databases – storing private data inside a local MySQL Database. All classes inside the app can read and write this data.