-1

So I am working on my app, and it parses data from the LoL (League of Legends) API, so far so good, but the only problem is that if the user closes the app, and reopens it parses the data again. I want the objects I parsed from the JSON data to be saved, once it initially parses them, instead of redownloading them every time I reopen the app. It slows my app down.

daesad
  • 55
  • 6

2 Answers2

1

There are a few ways to do that, but they all basically doing the same thing: serialize/de-serialize objects. The difference will be mostly what kind of persistence storage and what serialization mechanism are you using.

As for persistence you can use for example file, data base, etc.

Java provides human-unreadable binary serialization. Instead you can use JSON, XML, etc. formats. I assume Java built-in serialization will be the fastest, but it won't be deserialize if your class changed in the mean time.

Local persistence also would allow to map objects you parsed into database and load them pieces by pieces as needed.

C.A.B.
  • 465
  • 4
  • 12
0

Save your JSON data as a string in Android SharedPreferences. It is the most convenient and fastest method for you.

Using SharedPreferences

Muktadir Khan
  • 148
  • 3
  • 17
Dulaj Atapattu
  • 448
  • 6
  • 23