O'Reilly logo

Programming Chrome Apps by Marc Rochkind

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

files
Named files organized by a hierarchy of directories
KVP
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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required