I have a big string that represents JSON feed. My app downloads this feed from remote web service.
Questions:
1) Once I download JSON feed, where should I store it? Right now I am storing it in app Preferences and it works fine. I am just interested if there is any reason not to do that, or if there are better/faster options, like Internal Storage or something else?
2) When I am about to show data from this feed in my activity, I do something like this:
JSONObject jsonObj = new JSONObject(json_string);
JSONArray jsonArr = jsonObj.getJSONArray("root");
for (int m = 0; m < jsonArr.length(); m++) {
....
}
The problem is, the first line that parses JSON feed is sort of expensive. At my current size feed (that might grow in the future) it takes maybe half a second to complete, not much, but still a problem. For example, I click button to call activity (to show data) and this 1/2 sec pause is noticeable and not good.
To avoid this pause, I should probably parse JSON immediately after feed is downloaded. Then question is, where should I keep parsed JSON object?
i) I can't save JSON object to preferences since only primitive data can be stored there.
ii) Should I do parsing every time my app starts, and make my parsed JSON objects (I have more of them) global (on application level) so I can access them from all of my activities?
iii) Or, I believe my 3rd option would be to declare JSON objests static so they can be easy accessed from other activities?
What is the best way to do this?
THX.