Chapter    4

JSON for On-Device Persistence

A key aspect of mobile applications or games is the need for persistence on the device. Android provides a number of very good options for persistence, including relational storage. However, all the provided mechanisms that use the relational storage take a sizable amount of development time. This chapter provides a shortcut for a number of simple to medium persistence needs. The approach uses GSON/JSON technology to store object trees directly in non-SQL storage, such as the shared preferences and internal file storage.

JSON stands for JavaScript Object Notation. GSON is a Java library from one of Google Projects that uses JSON structure to serialize and deserialize Java objects to strings.

You will ...

Get Expert Android now with O’Reilly online learning.

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