Data persistence is a wide subject area. In this chapter we focus on selected topics, including:
Filesystem topics relating to the app-accessible parts of the filesystems (/sdcard and friends)—but we assume you know the basics of reading/writing text files in Java.
Persisting data in a database, commonly but not exclusively SQLite.
Reading data from the database, and doing various conversions on it.
Reading and writing the Preferences data, used to store small per-application customization values.
Some data format conversions (e.g., JSON and XML conversions) that don’t fit naturally into any of the other chapters.
ContentProvider, which allows unrelated applications to share data in the form of a SQLite cursor. We’ll focus specifically on the Android Contacts provider.
Drag and drop, which might seem to be a GUI topic but typically involves using a
FileProvider, a simplification of the
ContentProvider that allows unrelated applications to share individual files.
SyncAdapter mechanism, which allows data to be synchronized to/from a backend database;
we discuss one example, that of synchronizing “todo list” items.
Finally, we cover a new cloud database called Firebase from Google.
You want to know how to store files in internal versus external storage. Files can be created and accessed in several different places ...