LocalStorage not being cleared on app uninstall – Android 6

All we need is an easy explanation of the problem, so here it is.

i’m having a problem where the localstorage doesn’t get cleared when i uninstall the app (ionic app). It’s only happening on my Samsung S7 Edge with Android 6 (at least is the only device with Android 6 that i have).

The only way of clearing it is by Clearing Data/Cache through the Application Manager of the device…

It works properly on other devices… Since the localstorage implementation is pretty straightforward I have no clue why this is happenning…

Any ideas?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Android 6 has automatic backup on.

Did you try setting android:allowBackup=”false” and android:fullBackupContent=”false” in your manifest.xml?

android:allowBackup and android:fullBackupContent are properties of <application/> in application’s manifest.xml.

In ionic 2, you can find this under platforms folder also.
You can use these properties in case, if you don’t want your data backed up or if you want to include or exclude some resources.

I also struggled with it for a long time on Lenovo Vibe phone. This solved it.

Method 2

I had problems adding those lines to my AndroidManifest.xml in my cordova /progject/platforms/android folder – each time I did it was overwritten every time I compiled the app. I had to add the following to my /project/config.xml file in order to get the manifest edits to take:

<edit-config file="AndroidManifest.xml"
    <application android:allowBackup="false"/>
    <application android:fullBackupContent="false"/>

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply