How to clear Android app data in Cordova app - android

I'm using Phonegap Build for my application. I wonder is there any way to clear ALL app data (not just localStorage or cache) in my app? I have some problems with relogin in my app for Android. When I do localStorage.clear(), it seems like Android doesn't clean data. I also tried to clean cache at that moment (using cordova-plugin-cache-clear plugin). But if I clean app data manually (in phone`s settings) it works perfectly. Otherwise I have conflicts when I try to login again, as if Android use some old previous data. Other platforms work ok.

localStorage.clear should do it (I've used it successfully).
Normally I don't use it though, as (obviously) it cleans out everything.
So, for individual credentials, options and such I use localStorage.removeItem.
There's no need to clear the cache. localStorage calls have immediate effect, at least from the app's point of view.
Without seeing the login code it's hard to be more specific.

You can use this plugin to clear App data for Android and iOS apps:
https://github.com/dpa99c/cordova-plugin-clear-data
Another way, is using ionic framework. There is $ionicHistory.clearCache() which will clear app data.

When change the code and run in borwser by
cordova run browser
and haven't any change, then use:
cordova build
and run again:
cordova run browser

Related

React Native Hot Reloading

I have created a React Application via Expo CLI, while I run something via:
yarn web
I am able to open a QR code, and Switch to Tunnel and open that application via my Personal Android Device, it renders fine. But I have to make any changes, and I spin the server again using the same command, it does not seem to refresh content. It does refresh on Web, but does not on Android.
I have gone through few SO's posts and seen that we need a Hot Reload to serve contents dynamically. But when I shake the phone rigorously, I do not find any thing such as Hot Reload to enable it.
This is what I am getting:
I need two things now so to unblock me:
How to enable Hot Reload?
How can I rebuild the package so that I can access the latest from Android mobile
I used expo start instead of yarn web,
And it has helped me in auto reloading

How do I update js file/code on App Launch

I want a react-native app, when started on a device to check for some update and download it and use it instead of old js file.
I have checked out Codepush but as an alternative I am searching for a simple and clean implementation for a small case usage.
I just want some js code/file to be updated without bundling the app again or updating it through playstore, maybe suggest some other options too.

Ionic Storage is not working on Android device

I'm new to the Ionic Framework, and I'm doing an app that preserves the user login so it can show a different page when user is logged. And for doing this, I'm saving the user ID into the local storage.
This works fine when I do ionic serve and testing the code on browser, but it doesn't work on my Android device (so I run ionic cordova run android). Why? I have set the Storage right by using IonicStorageModule.forRoot() in app.module.ts -> imports[...]. Here's my code and my Ionic specs:
I just figured out my problem and built a solution. On the very first access in my app userLoggedID is completely empty (it wasn't neither undefined nor null), so I attached a catch() instruction and now the code works fine.
LOG:

Android Project using Cordova 3.5 caches data in memory

I have recently built a hybrid Android Project using Jquery Mobile, Andorid SDK 22.3 and Cordova 3.5 plugin. The application was build successfully. But while testing we observed that application is caching data in its memory.
E.g. when we login into the App using user credentials, the apps store the credentials. And in next attempt, it takes previously used credentials to login.
The issue gets resolved if we explicitly clear the cache memory of App. But again after next login, it stores the cache data.
Can anyone please suggest how to clear the cache memory programmatically?
Thanks and Regards,
You can solve your problem by adding the following meta tag on your header tag.
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

How can I clear my app's localStorage on my Android emulator each time I install it?

I want to clear localStorage for my app each time I install it from Eclipse to simulate installing the app for the first time.
How can I do this?
Thanks!
I answered this, specifically for Android, here - Programmatically clear PhoneGap/Cordova app's cache on Android to simulate a fresh install?
There are no hooks in Eclipse, but you could probably do this with Ant. You can add a task that executes the clear command (pm clear my.package) before uploading the app. If pm clear does not work, you can write a small script and start it on the device before uploading the app
There is also the Android run configuration's 'Wipe user data' checkbox, but it only works on emulator startup.
I'm using Chrome inspector (chrome://inspect) which very nicely shows the connected Android device. From there you can just hit Resources to access and modify the localStorage
I am not sure if you want it programmatically or via ADB - in any case this should solve it
How to programmatically clear application data
For testing purposes, you can drop a quick local storage clear statement:
localStorage = ""
Make sure to remove this before release.

Categories

Resources