onSavedInstanceState vs. SharedPreferences

前端 未结 2 1420
半阙折子戏
半阙折子戏 2020-12-18 05:05

I have 7 activites all with back and forth navigation buttons between the rest; activites consist of editTexts, Spinners, textViews, TimePickers, DatePickers, and checkboxes

2条回答
  •  天涯浪人
    2020-12-18 05:49

    It will depend on how you want to manage the data. Both options (and more) are feasible:

    • 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

提交回复
热议问题