Comments (10)
I am wrapping everything inside platform.ready() as you can see below, and the get returns null everytime.
constructor(platform: Platform, public deploy: Deploy,public modalCtrl: ModalController, public authSrvc: AuthService,
public localStorage:Storage, public chatSrvc:ChatService, public prefSrvc:PrefService) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
console.log('[App Component] SQLite length: ');
localStorage.length().then((n)=>{console.log('[App Component] SQLite length: ' + n);});
localStorage.set('test',true).then(()=>{
localStorage.get('test').then((test)=>{
console.log('testing of sqlite was ' + test); //this is always null, even though I just set it to true.
//...
});
});
});
}
I've seen that @mirkonasato has submitted a pull request for this here #21 . Please @jgw96, could you take a look?
I am using ionic 2.1.8, cordova 6.3.1, ionic storage 1.1.6 and cordova-sqlite-storage 1.5.0.
Thanks!
from ionic-storage.
Hello, thanks for using Ionic! It seems that this issue is most likely caused by your use of new
with storage and by putting storage
in your imports
array. Could you take a look at the docs for ionic storage and give it another try? Thanks!
from ionic-storage.
From @jherediagu on November 1, 2016 11:27
Yes, it's lost data, I have the same problem, I solve it with localforage, like this:
import localforage from 'localforage';
localforage.setItem<any>('foo', 'bar');
localforage.getItem<any>('foo').then( (value:any) => {
console.log(value);
});
from ionic-storage.
Thanks for the info. Unfortunately I cannot reproduce this issue, would you posting a repo or a zip of your project that I can use to reproduce this issue?
from ionic-storage.
I was seeing similar behavior and then wrapped my storage method calls in platform.ready().then(() => { });
.
Solved my problems.
from ionic-storage.
Could be the same issue as #20
from ionic-storage.
@jgw96 I'm having the same problem on Android with the latest versions, whereas 1.0.x were working okay. I checked just in case and I'm not using new
nor have Storage in my app module imports.
I agree that it seems related to #20, as I noticed to have keys in localstorage
and Storage should always pick SQLite as the engine (I have the plugin installed).
Thanks!
from ionic-storage.
I submitted PR 19 weeks ago as a possible fix for these issues. Would be nice if somebody could look at it.
from ionic-storage.
I faced the same issue and found a workaround. Reading above comments, i came to conclusion that rootpage should not be set until platform loads. I initialised the rootPage inside platform.ready().
The code looks like this:
export class App {
. . .
rootPage;
constructor(private storage: Storage, public platform: Platform) {
this.platform.ready().then(() => {
this.rootPage = ||your login page||;
StatusBar.styleDefault();
Splashscreen.hide();
});
}
. . .
This works for me, hope it helps all. Do try and share your experience and thoughts.
from ionic-storage.
Fixed with #21
from ionic-storage.
Related Issues (20)
- Need help configuring the storage manager
- (question) rationale behind IndexedDB being the 1st driver in driversOrder ?
- The NgModule 'IonicStorageModule' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.
- IOS app doesn't retain state after ionic/storage version(3.0.6) upgrade for ionic app HOT 1
- Not working when re opening the app in OFFLINE mode HOT 1
- Angular 15 updates in source code not available in npm HOT 5
- Angular 16 support HOT 22
- iOS 16.1 SDK update clears ionic storage HOT 2
- Unable to use SQLite for native storage (Android) but only IndexDB and localstorage works ,Error: No available storage method found HOT 2
- Error: No available storage method found when using CordovaSQLiteDriver with Ionic Storage HOT 1
- SQLite Installation HOT 1
- localForage-CordovaSQLiteDriver maintenance
- Storage access blocks the main ui HOT 2
- ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AppModule)[AuthGuard -> StorageService -> Storage -> Storage]: NullInjectorError: No provider for Storage! HOT 2
- Method get is not working HOT 3
- Angular 16 upgrading HOT 3
- Random data losses on iOS HOT 4
- Update README for Angular users HOT 1
- Cannot find Driver enum. HOT 1
- switched args in storage.forEach documentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ionic-storage.