Best way to save some 0/1 values


#1

Hi all, in 2-3 views of my new app I need to show some alert() (I will transform them in more beautiful and UX items later) only for the first time that the user arrive on these views. If user closes my app and reopen it and go to 1 of these views my app does not show any alert().

Which is the best way to store that the user has see viewsX ? Ok for viewsX: 0/1, but where ?

No sessionStorage because I need to store this value in permanent way.

LocalStorage ?

Thanks.


#2

Local storage is more permanent, but if the space on the phone gets filled up or the user deletes the app it might wipe that (Or in some cases even wipes the web view caches for the browser).

A more persistant storage option is a SQLite. And if you’re storing 1’s and 0’s i would recommend just storing them in a JSON object if you go the file route. JSON objects are SO easy to work with in javascript since it directly translates into a mutable entity.

There are a lot of threads on the forum about SQLite and file storage so just a search for those.

I would say the most permanent is if the user is already logged in, you could store those in their account information if that’s a possibility. It would just allow for that to persist even if they uninstalled and reinstalled the app and logged in (of course your app would have to have Auth for this to all work)


#3

I would only use the localstorage for those things (if you have a countable number of views and so on…, keep in mind you have only round about 5MB localstorage).

If someone deletes the app and reinstalls it… the user could see the information again. In most apps i am using this is the default-behavior.
In that case sqlite is a little bit overacted i think. Do add a plugin to your app and initialize it… and only for an app with 2-3 views. The app should be as fast and small as possible.

That are unnecessary information to store permanently in the backend database.