Im using database to store messages, and if i uninstall my app and again reinstall the same app, the db remains same, but i want to clear my database, how to solve this?
To listen the uninstall event you have to implement a broadcast received, like:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".UninstallIntentActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DELETE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="package" />
</intent-filter>
</activity>
</application>
And then in your UninstallIntentActivity you have to use the next line to delete your database:
context.deleteDatabase(DATABASE_NAME);
You can see more about this topic here Listen Broadcast Before application uninstall
I hope this works for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With