Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically clear PhoneGap/Cordova app's cache on Android to simulate a fresh install?

This is related to my previous question of 'How can I clear my app's localStorage on my Android emulator each time I install it?'.

It also builds on 'How can I clear the Android app cache?' and 'How to programatically clear application data?'.

None of the above questions give a straightforward answer that is applicable to Android PhoneGap/Cordova applications. This blog post by Igor Hrupin covers the situation in the context of a native Android app, so this question extends that to cover Cordova.

I will post an answer myself, but I am a total Java noob, so please edit to improve.

like image 383
Jasper Mogg Avatar asked Nov 29 '22 02:11

Jasper Mogg


1 Answers

just saw this one. It can be done with one line. I am not sure if this is what you want but it serves my purpose which is clearing the cache on startup

https://coderwall.com/p/aj79eg

super.clearCache(); // just add This Line
super.loadUrl("file:///android_asset/www/index.html");
like image 135
Mohammed A. Al Jama Avatar answered Dec 04 '22 15:12

Mohammed A. Al Jama