1

I work on an app, that won't have Internet-Connection during most of the time where it will be used.

The data for this app will be stored on a server and for updating the data it should be able to connect to that server and basically 'download' all of the new data or update the changed ones. Therefore I would need to be able to save that data on the device the app is running on, to be able to then retrieve it, when it is no longer connected.

The only thing that I found was localStorage, however, in my understanding, the data is not saved permanently but only temporary. I would need to be able to save it permanently on the device, until it connected and updated itself once again.

Is this in anyway possible?

violetleaf
  • 111
  • 2
  • 12
  • Look into [IndexedDb](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) this is a local db that every device has and the data persists until it is removed it also has 50mb of storage – Smokey Dawson Aug 20 '19 at 05:48

3 Answers3

5

You Can use localStorage and sessonStorage for this, Please refer below code:

localStorage

Set Value

let items="Item1";
localStorage.setItem(items,"Value")

Get Value

localStorage.getItem(items)

sessionStorage

Set Value

let items="Item1";
sessionStorage.setItem(items,"Value")

Get Value

sessionStorage.getItem(items)
  • 1
    Is it possible to connect this with a database, like SQLite for example? – violetleaf Aug 20 '19 at 08:01
  • Localstorage and sessionstorage don't store data permanently. If browser is closed, data in localstorage and sessionstorage will be cleaned. – whitefang May 02 '21 at 21:03
2

localForage

this is best library so far, it will figure out which persistent storages, your device supports and will save there

onik
  • 1,579
  • 1
  • 11
  • 19
1

use browser localstorage! but it isn't safe!

jijishthomas
  • 61
  • 2
  • 10