Android的保存应用程序上下文 [英] Android save Application Context

查看:126
本文介绍了Android的保存应用程序上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的应用程序上下文保存数据,它为我工作很好,但问题来了,当我preSS home键,并采取一些其他的应用程序,很长一段时间我的应用程序失败后,回到我的应用程序,在应用程序上下文中没有数据,我怎么能保存应用程序上下文

i am using application context for saving data, and it work fine for me ,but the problem comes,when i press home button and take some other application and return to my application after a long time my app fail, no data in application context, how can i save the application context

推荐答案

这<一个href=\"http://stackoverflow.com/questions/4136154/does-the-android-application-context-ever-get-destroyed\">question应该帮助你。你可以存储在共享preferences应用程序上下文。当恢复活动,第一次测试,如果应用程序上下文是空的,如果是这样,然后加载从共享preferences数据。

This question should help you. You could store the application context in shared preferences. When resuming an activity, first test if application context is empty and if it is, then load data from shared preferences.

这篇关于Android的保存应用程序上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆