Chapter 2. Local Files, Sync Files, and External Files

The subject of this chapter and that of Chapter 3 is storage outside of an app’s memory that persists from launch to launch. Chrome Apps can access seven types of storage (see Table 2-1), which offer the following three kinds of data structures:

Named files organized by a hierarchy of directories
Key-value pairs, which are a collection of keys and their values
indexed KVP objects
Key-value pairs organized into objects that are indexed for speedy access

Some storage is sandboxed, which means that it’s accessible only to the app, determined by the app ID, and kept separately for each user, determined by his or her Google account. Storage might also be synchronized (synced, for short, which we’ll use throughout this chapter and elsewhere in the book), which means that it’s automatically copied to multiple computers to keep them consistent.

As Table 2-1 shows, Local Files and IndexedDB are standard APIs available to any web page, whereas the others are only for Chrome Apps.[1] There is a standard API for Local Storage, as well, but it’s not available to Chrome Apps, and the Chrome API variant is better anyway. Some browsers, including Chrome, implement a Web SQL Database API, but it’s not available to Chrome Apps either.

We explore the first three types of storage in this chapter, Chapter 3 discusses the three KVP storage types, and Chapter 5 looks at Media Galleries.

Table 2-1. Storage available to Chrome Apps
Storage ...

Get Programming Chrome Apps now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.