开发者

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

开发者 https://www.devze.com 2022-12-12 03:26 出处:网络
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.

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

精彩评论

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