Praveen Vishnu
Praveen Vishnu

Reputation: 443

Difference between Ionic Storage and Native Storage?

I'm Actually using Ionic Storage. and I heard About The Ionic Native Storage I Don't Know the Exact Difference Between Them. Which One Is Preferred to use?

Upvotes: 9

Views: 10404

Answers (3)

Tariq Saeed
Tariq Saeed

Reputation: 1193

Nowadays I work with ionic 4 and I have experienced unpleasant latency of the @ionic/storage module, but after I switched to the native storage I got a better performance. and by the way you still can use it while testing with the browser using the ionic cordova run browser command not the ionic serve command.

So what I am trying to say that native plugins always win in the matter of performance.

Best Wishes

Upvotes: 6

PailletJP
PailletJP

Reputation: 310

the principal difference is this: Native Storage is a Cordova Plugin, so only work in devices. Its a little faster than Ionic Storage on devices, because uses the native functions of the device to store Key/Value data.

Ionic Storage is a not a Cordova Plugin, is a javascript library, and can be used both in Devices and Navigators.

There are no big difference between them, i prefeer Ionic Storage because i can realize faster tests on browser during development.

Upvotes: 7

Gabriel Barreto
Gabriel Barreto

Reputation: 6421

They have basically the same purpose and both work with key/value to store items, but i think Ionic Storage is better and i'll tell why.

The Native Storage need and will only work with the plugin instaled, so if there's no plugin or if it's a webapp the user can't use the storage. It's intended to be used because iOS may remove stored data when running out of memory.

The Ionic Storage works in a diferent way, you can save your values in the IndexedDB, wich is a type of storage for the browser, but if you install te SQLite plugin it'll automatically priorize to save your data in SQLite so there's no loss when iOS is out of memory.

So when using with SQLite, if in a browser running as a webapp the user can still save data, because since there's no plugin in the web it'll use the IndexedDB, and if there's no IndexedDB then it'll use localStorage.

And you don't need to learn SQLite to save with the plugin, the Ionic Storage will do all the work for you, you just need to use the key/value as the same way you would use for the Native Script or the localStorage.

Which one is preferred? It's all up to you, but i see more advantages in Ionic Storage.

Check out the Ionic Storage Docs.

Hope this helps.

Upvotes: 17

Related Questions