简体   繁体   English

关闭后如何保存我的Android应用程序的状态?

[英]How to save state of my android app after closing?

I've been working on an app lately and didnt figure out how to save the state of my application after closing ,i found something about SharedPreferences but i saw that it saves a (key,value) ,it can help if i want to store the username and the password but how to store the whole state of the app ? 我最近一直在开发一个应用程序,在关闭后没有弄清楚如何保存应用程序的状态,我发现了一些有关SharedPreferences的信息,但是我看到它保存了一个(key,value),如果我想存储它可以提供帮助用户名和密码,但是如何存储应用程序的整个状态?

Thanks. 谢谢。

Please see here . 请看这里 It has exactly what you need. 它正是您需要的。 Just override onSaveInstanceState and save whatever custom values you may have to the bundle, and retrieve it by overriding onRestoreInstanceState . 只需覆盖onSaveInstanceState并将任何自定义值保存到包中,然后通过覆盖onRestoreInstanceState检索它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM