My android app fetches a JSON structure开发者_Go百科 from the net. It's somewhat large, maybe 2,000 characters in length. I need to store it away when my app gets killed so I can recover it quickly. I've tried saving it to an sqlite database, but that takes about 400ms, kind of long. I wonder if it's bad practice to just dump it into the save bundle:
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
String jsonString = myObject.toString();
outState.put("test", jsonString);
}
or are we really only supposed to be putting the smallest of items in bundles?
Thanks
how about SharedPreferences
?
If you want to preserve an object across simple activity changes, try Activity.onRetainNonConfigurationInstance().
精彩评论