Delete storage after uninstall app

I’m using Ionic 2 and I have a problem with the Storage (from @ionic/storage): this is not deleted after the uninstall of the app. Is there a way to delete the storage when the user uninstall the app?

How are your verifying that the data is not deleted? How do you view the data? What platform?

I can see the old data in the storage after a new installation of the app.
I’m using Android.

With Data you mean you are seeing the Folder of your App with the Files of your App in it in your Internal Storage of your Android Phone? Are you creating such a Folder to store files in your App?

No. I’m reading the Storage via app like:‘user’).then((value: any) => {


and after I uninstalled the app and then installed it, the value of the “user” is the same of the value before than i uninstalled the app.

t0: the value of “user” is xxx.
t1: uninstall the app
t2: install the app
t3: the value of user is again xxx

Ah okey. Well anyway why do you not use the Native Storage Cordova Plugin.
With this Plugin you could do something like remove.item('uservalue') at the First Startup of the App to make sure the User Value is deleted. And then you could insert the Value “FirstStartupChecked” with “Yes” so the App doesnt remove the new Value on the next normal Startup.

How could you detect the First Startup of the App?

Well lets say in the First Startup you check if there is any value stored like so (Note that with Native Storage you wouldnt need this code anyway because it deletes the items after deinstall but only to be on the safe side you can do it if you want):
Do this in the app.component.ts file between this.platform.ready().then(() => {

//Here Check if the Item is set to the Storage -> if not its the first startup of the App
if(Native.Storage.getItem('FirstStartupDone') === null || Native.Storage.getItem('FirstStartupDone') === "")
   //Here Set the Value because she isnt set at the moment 
   //So on the next Time the App Starts it will not get into this if
    NativeStorage.setItem('FirstStartupDone", "Yes");
   //Now Clean the UserData if the Userdata exists in your Storage
   //Well now you have the First Startup without that Data
   //This gets called if its not the first Startup of the app so simply do nothing here

And in the Activity where your Userdata gets Stored do it like so:

NativeStorage.setItem('Userdata", "XXX");

And dont forgett to import Native Storage in your ts files:

import { NativeStorage } from 'ionic-native';

And you can install it with this Cli:

ionic plugin add cordova-plugin-nativestorage

Note this is only a Workaround for you that it works for now but you really should find the real Problem someday why your Storage doesnt get removed after deinstall of your app.

if you want to also get error outputs if you cant store or get your data do it like this:
NativeStorage.getItem('Userdata').then( error => console.error('Error get UserData', error));

Also Note that Native Storage doesnt work in IonicView or Browser because its a Native Plugin

But the problem is the following.
I install the app, so the value of FirstStartupDone is Yes.
Then I uninstall the app e I re-install it.
After I re-installed the app, the value of FirstStartupDone is again Yes, this is the problem.

I dont thinks so because the Native Storage Plugin will remove the Stored Items to 100% after deinstall. Try it.

I solved using the following (from the doc

import { Storage } from '@ionic/storage';

export function provideStorage() {
  return new Storage(['sqlite', 'websql', 'indexeddb'], { name: '__mydb' }// optional config);

  declarations: ...,
  imports: ...,
  bootstrap: ...,
  entryComponents: ...,
   providers: [
     { provide: Storage, useFactory: provideStorage }
export class AppModule {}

Thx for your anwser.

The issue might be related to iCloud backuph. You can prevent backing up by adding this to your config.xml:

More info:

Can you paste the conf?

Sorry having trouble pasting from my phone. It shows the config when I edit but does not display after I save. Checkout the link for the config

This is happening because, data is getting restored from backup. You can stop android from doing that by setting in config.xml.Set android backup to false