Storage not persistent using Ionic Storage - ionic-framework

I am attempting to utilize the Ionic Storage library to keep track of settings for my app. However, I am having an issue where each time the app is restarted, the storage is wiped. At least, it appears that way.
I'm storing the data:
this.storage.set('language', 'es');
and attempting to retrieve:
this.storage.get('language').then((val) => {
this.mylang = val;
}).catch((errorGet: any) => {
console.error(errorGet);
return;
});
Retrieving the data works if I don't quit the app. But if I quit and re-open, the data is gone. It is using SQLite as far as I can tell (per debug messages in XCode when building & testing there).

I think it's an issue with Ionic-storage, you can check the issue here https://github.com/ionic-team/ionic-storage/issues/165 try to implement another solution SQLite or local storage

The best way is to use back-end for persistent storage like Rest Full API or a database.
In this way you can manage the storage problem(This is my suggestion).

Related

If I use firestore offline to store the data for the chat app, do I still need sqlite, flutter

I wanna create a chatapp for my friend, and now remote serve I will use firestore and locally sqlite, but I realized it is default for firestore to save data offline, so my question is I have some data like message, or sending setting for the app, is it ok just to save them in firestore offline which seems automatically and no extra costs.
It depends on what you want or need.
If you want to use the offline persistance only for storing in case internet is not there at all. Firebase supports that out of the box. But you need to keep in mind to do you calls carefully. Because on a slow internet connection, if you tell the Firebase access to wait for the online behavior. It will not be using the local first and you might not be able to show the data. Check the question here
Also if you want to use the offline persistance from Firebase, be mindful that the data size has a default of 40 megabytes of limit. You might assign that by your self. You can check this link
BUT, if you want to have heavy data manipulations and have more control over your data SQLite is more suggested.
My opionion: I think Firebase Offline persistance would be enough for you, so go for it.

Data is not persisting for IndexedDB using Flutter and package Hive on web(chrome) browser

I'm using the flutter package Hive
The problem that I am encountering is that my website's data is not persisting for IndexedDB - web(chrome)
Has anyone else encountered inconsistency with data stored in IndexedDB for chrome?
Are there any additional steps outside of using the Hive package such as requesting persistent permission that I have to implement in order for the data to be stored?
Any feedback will be appreciated.
You don't even need to request the persistent storage permission to be able to store data. Persistent storage just makes it a bit more durable. So most likely, the data is never being written to IndexedDB in the first place. Could be an issue with your code or with a library you're using. Hard to say without seeing your code, especially since I've never used Hive.
This is a flutter project, using the hive package. It works fine on mobile devices, but when running the app in chrome the data gets lost after a refresh
Data after the initial load and initialisation
Empty boxes after refresh

IndexedDB persistence in PWA application

PWA application storage (IndexedDB) isn't able to provide data persistence.
In case that PWA is pinned to home screen it is possible to clear all application data from browser by clearing browsing history.
It might be unclear for users that cleaning browser data can affect pinned application and unsynchronised data will be lost.
Is there any way to avoid this?
The only way I see for now - turn back to native apps.
The clear storage mechanism in browsers is to put the user in control of their device.
This is why you as an application should never (native or web) assume your cached assets are cached.
If it is absolutely important to you to make sure you have core assets and data persisted then you need to have some sort of integrity check when the service worker initiates. That way you can restore cached state in case the application goes offline.
You also need to realize the operating system, looking at you iOS, will purge data when it feels like it (think when the available disk space gets critical), which takes you out fo control. It does this for native apps too as far as I know.
I do not know a way around that. The function in Chrome to "clear storage" (for example) does exactly that. I suppose it is reasonable for a user to be able to remove any data from their own device, but I agree it is not a good situation for the developer.
This is not possible.
The Storage API provides a StorageManager.persist() method to request the user explicit permission to persist data until deleted by the user itself:
if (navigator.storage && navigator.storage.persist)
navigator.storage.persist().then(function(persistent) {
if (persistent)
console.log("Storage will not be cleared except by explicit user action");
else
console.log("Storage may be cleared by the UA under storage pressure.");
});
If the local storage is running out of space, the User Agent will start automatically pruning cached resourced except the ones set as "persistent". However if the user itself chooses to clear the local data, there is no way to prevent this.
As far as I am aware, there is no event you can intercept in order to detect a browser clear action from the user.
See API reference doc :
https://developer.mozilla.org/en-US/docs/Web/API/StorageManager/persist

Where to find stored data with local storage (Ionic2) on Android

I developed an application for Android with Ionic2 framework. I used Local storage functions to handle data.
Now, I want to replace local storage by database with some API calls.
And before switching to my API, I wish to extract the application data in order to no lost them.
Q1: That why, I wonder where is the path for the local storage data? In other words, where can I find the file with my stored data?
Q2: If retrieving my data isn't possible. I was wondering: If I modify the application with a extract function, when I reinstall it, will it delete my data or leave it as it is? (and so extract my data easily)
Thanks for your help!
I hope I gave enough information.
Local storage doc: https://ionicframework.com/docs/building/storage/
Which use localForage: https://github.com/localForage/localForage

iOS saving core data to server/cloud

I'm using core data in our iOS universal application and want the ability for the user to back their data up to our server. So they can log in with another device and pull down that data to that device. Has anyone got any advice on this? I want to analyse the data at the server to synchronise information with our stores as well, so the data must be readable via the server end as well.
I want to send the entire core data store over in one push, so will be an XML mashup of entities from the core data store that will be deciphered on retrieval.
How can I do this?
Have accomplished this using GDataxml to build the xml string and push it through a web service at the server end. Performance is great.
Your duplicating some iCloud functionality here. Why not leave the cloud storage and retrieval to iCloud and then when the app starts, synchronise with your server