java - Different One-time screens -


i wondering one-time screens. i'll need use few one-time screens on app.

first of all:

one-time screen, saves user selection 3 options (i use image buttons) , let him go further, next time user comes activity, opens activity of option user selected earlier.

i know need use code sharedprefences , saving sd-card/app memory.

yeah, should consider simple state machine design.

say created enum, eruntimestate, has 2 components;

enum eruntimestate { initialize, been_initialized; }

you can view useful example of saving data using sharedpreferences here, if need reminder. when using sharedpreferences, you're able query existing storage flag application, , if variable hasn't been set before, can set it's default value. so, when application first runs, can use sharedpreferences check saved instance of eruntimestate, using initialize default picked if there's no existing save data.

once done, can use eruntimestate you've fetched configure contents want load on screen; can display first-time launch interface. have make sure once state entered, use shared preferences save eruntimestate value of been_initialized, don't execute initialization step again on next run.

of course, defining enum, we're not limited 2 states. otherwise we'd use boolean, , that's inflexible.

as aside, might quite hard debug! might want make sure don't save flag in initialization state whilst you're debugging, otherwise you'll have keep clearing of application's cached data in order emulate initial launch.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -