In this blog post, we'll get practical one more time. Often Android apps require to store smaller objects, for example user information. On one hand, it's often overkill to add a database to the app for just this purpose. On the other hand, it's a hassle to store everything in the SharedPreferences
if you've a more complex object structure.
In the next few minutes you'll see how you can utilize Gson to make this a very easy process.
Of course, this will not be the only post in our Gson series. If you're interested in the other topics, check out our series outline:
Gson Series Overview
- Mapping of Enums
- Mapping of Circular References
- Generics
- Custom Serialization for Simplification (Part 1)
- Changing the Default Serialization with Custom Serialization (Part 2)
- Custom Deserialization Basics
- Custom Instance Creator
- Customizing (De)Serialization via @JsonAdapter
- Custom Deserialization for Calculated Fields
- On-The-Fly-Parsing With Streams
- ProGuard Configuration
- Low Level Parsing
- Storing Data in Android's SharedPreferences
- How to Deserialize a List of Polymorphic Objects