开发者

Reasonable size of data to store in Bundle on onSaveInstanceState()?

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().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜