SharedPreferences stores private primitive data, is automatically persisted between sessions, and is often used for customizable app settings. SQLite databases store larger amounts of structured private data locally. Internal storage saves smaller private data sets while external storage saves larger non-private data. The document provides examples of using these storage options to save and retrieve data like preferences, images and database records in an Android app.
25. Storage areas are classified as
internal or external
Internal memory usually used for
smaller, application private data sets
External memory usually used for
larger, non-private data sets
26. FileOutputStream
openFileOutput (String name, int mode)
Open private file for writing. Creates the
file if it doesn't already exist
FileInputStream
openFileInput (String name)
Open private file for reading
Many others. See documentation.
27. If a text file does not already exist,
application writes text to that text file
Application then reads data from the
text file and displays it
34. Application reads an image file from
the resources directory
Copies that file to external storage
Reads image data from the file in
external storage
then displays the image
38. Temporary files that may be deleted by
the system when storage is low
Files removed when application
uninstalled
41. SQLite provides in-memory database
Designed to operate within a very small
footprint (<300kB)
Implements most of SQL92
Supports ACID transactions
Atomic, Consistent, Isolated & Durable
46. Application creates an SQLite database
and inserts records, some with errors,
into it
When user presses the Fix button, the
application deletes, updates and
redisplays the corrected database
records
52. Databases stored in
/data/data/<package name>/databases/
Can examine database with sqlite3
# adb -s emulator-5554 shell
# sqlite3 /data/data/
course.examples.DataManagement.Data
BaseExample/databases/artist_dbd