onSavedInstanceState与共享preferences [英] onSavedInstanceState vs. SharedPreferences
问题描述
我有7 activites都与其他国家之间来回导航按钮; activites由editTexts,纱厂,textViews,TimePickers,DatePickers和复选框。
I have 7 activites all with back and forth navigation buttons between the rest; activites consist of editTexts, Spinners, textViews, TimePickers, DatePickers, and checkboxes.
我希望所有的用户界面是present,并通过一个应用实例的导航保存;然而,在应用程序终止一切都需要为默认值。
I want all UI to be present and saved through navigation of an application instance; however on application termination everything needs to default.
我的第八活动收集所有用户界面和地方到电子邮件。 。 .fyi
My 8th activity collects all UI and places into an email . . .fyi
我有很多了解双方onSavedInstanceState和放大器;保存数据为活动奔波的共享preferences方式。 。
I have read alot about both onSavedInstanceState & SharedPreferences way of saving the data as activities go back and forth . . .
这会为我更好呢?
推荐答案
这将取决于你想如何管理这些数据。这两个选项(及以上)是可行的:
It will depend on how you want to manage the data. Both options (and more) are feasible:
- 如果您要填写一次,并保持数据,即使该应用程序就会被杀死,用
共享preferences
。 - 如果它是易失性数据,将有重新输入不同的其他时间(即天以后),然后使用
onSavedInstanceState
。 - 如果你想保持多个数据集在同一台设备上,然后用
SQLiteDatabase
- If you want to fill once and keep the data even if the app gets killed, use
SharedPreferences
. - If it's volatile data that will have to be reentered differently some other time (i.e., days later), then use
onSavedInstanceState
. - If you want to keep multiple datasets on the same device, then use a
SQLiteDatabase
这篇关于onSavedInstanceState与共享preferences的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!