concept datum in category android

This is an excerpt from Manning's book RxJava for Android Developers.
The updateSearchResults function is the consumer of the data. The function does something with the data every time a new value arrives.
public void setData(SymbolType[][] gameState) { // Save data for drawing this.gameState = gameState; #1 // Schedule redraw this.invalidate(); }The drawing function is a separate platform function. It isn’t advisable to directly call it, and thus you need to save the data until you need it here. You can see the full code in the online example.

This is an excerpt from Manning's book Android in Action, Third Edition.
Sharing files or databases directly is discouraged on the Android platform, and is enforced by the underlying Linux security system, which prevents ad hoc file access from one application space to another without explicitly granted permissions. Data stored in a ContentProvider can be traditional data types, such as integers and strings. Content providers can also manage binary data, such as image data. When binary data is retrieved, the suggested best practice is to return a string representing the filename that contains the binary data. If a filename is returned as part of a ContentProvider query, the application shouldn’t access the file directly; you should use the helper class, ContentResolver’s openInputStream method, to access the binary data. This approach navigates the Linux process and security hurdles, as well as keeps all data access normalized through the ContentProvider. Figure 1.5 outlines the relationship among ContentProviders, data stores, and their clients.
Android provides several ways to store and share data, including access to the filesystem, a local relational database through SQLite, and a preferences system that allows you to store simple key/value pairs within applications. In this chapter, we’ll start with preferences and you’ll create a small sample application to exercise those concepts. From there, you’ll create another sample application to examine using the filesystem to store data, both internal to the application and external using the platform’s Secure Digital (SD) card support. You’ll also see how to create and access a database.
Beyond the basics, Android also allows applications to share data through a clever URI-based approach called a ContentProvider. This technique combines several other Android concepts, such as the URI-based style of intents and the Cursor result set seen in SQLite, to make data accessible across different applications. To demonstrate how this works, you’ll create another small sample application that uses built-in providers, then we’ll walk through the steps required to create your own ContentProvider.
We include a reference to a SQLiteDatabase object; we’ll use this to store and retrieve the data that our provider handles
. We create, open, or upgrade the database using a SQLiteOpenHelper in an inner class
. We’ve used this helper pattern before, when we worked directly with the database in listing 5.10. In the onCreate() method, the open helper sets up the database
.
After our setup-related steps, we come to the first method ContentProvider requires us to implement, getType()
. The provider uses this method to resolve each passed-in URI to determine whether it’s supported. If it is, the method checks which type of data the current call is requesting. The data might be a single item or the entire set.
Listing 12.8. XML document containing data for the field service application
<?xml version="1.0" encoding="UTF-8" ?> <joblist> <job> <id>22</id> <status>OPEN</status> <customer>Big Tristan's Imports</customer> <address>2200 East Cedar Ave</address> <city>Flagstaff</city> <state>AZ</state> <zip>86004</zip> <product>UnwiredTools UTCIS-PT</product> <producturl>http://unwiredtools.com</producturl> <comments>Requires tuning - too rich in the mid range RPM. Download software from website before visiting.</comments> </job> </joblist>

This is an excerpt from Manning's book Android in Practice.
If you need to persist data from your application to the device, then Android has you covered. Android ships with SQLite, a fully transactional database engine based on the SQL-92 standard. SQLite is a relational storage engine. It stores data in tables (called relations in database theory), much like MySQL, Oracle, or DB2. But its architecture dramatically differs from conventional database management systems (DBMS) like the ones mentioned.
First, SQLite doesn’t require a client-server architecture. With a client-server DBMS, a server process listens for incoming requests from one or more client processes, transferring data back and forth using interprocess communication (IPC—typically via sockets). This is required for a client to query a remote database, for example over the Internet. SQLite can be embedded directly with the application that uses it, communicating with it via simple function calls instead of complex IPC mechanisms.
Data is a precious thing and will last longer than the systems themselves.
Listing 7.4. Using a FileDescriptor to guarantee data is written to the filesystem
public static boolean syncStream(FileOutputStream fos) { try { if (fos != null) { try { fos.getFD().sync(); } catch (IOException e) { Log.e(Constants.LOG_TAG, "Error syncing fos " + e.getMessage(), e); } return true; } return false; }
. We create, open, or upgrade the database using a SQLiteOpenHelper in an inner class
. We’ve used this helper pattern before, when we worked directly with the database in
.
. The provider uses this method to resolve each passed-in URI to determine whether it’s supported. If it is, the method checks which type of data the current call is requesting. The data might be a single item or the entire set.