Reputation: 137
IF i am trying to uninstall from setting of mobile(Settings-> app manager) then I want to display alert message "are you sure want to save database your uninstallING app ?
. if yes then i want to backup database and no for uninstall just like uninstall form setting as usual.IS THAT IS POSSIBLE OR NOT?
Or
Can i defined when build apk to backup database of current app in menifest file., is it possible. I try set android:allowBackup="true" in manifest file but could not understand how to work this or not or any other option available please forward me message..
Edited:
Other option, should i give message when uninstall app or edit below dialog box and give option with check box, with one of them database backup.
Upvotes: 3
Views: 2661
Reputation: 1576
You can. You can do this with device administrator api.
Upvotes: 0
Reputation: 7306
It is not at all possible
You can get the uninstall alert by using the broadcast receiver but You got broadcast only for other application's uninstall but never for your own application.
Reason : If you write broadcast to get uninstall notification for your app and when ever User uninstall your app that broadcast has been deleted/removed/unregistered before notifying you. So its not at all possible to get Notification of uninstall of your own app.
Upvotes: 1
Reputation: 8134
Short answer: No, that is not possible.
The backup of database can be taken when the app runs. Settings -> App Manager is Android System domain, you cannot program your app to behave in any xyz manner under that scope.
Unless you want your app to run over custom controlled environment with rooted devices.
Edit according to the edited question:
Whether to allow the application to participate in the backup and restore infrastructure. If this attribute is set to false, no backup or restore of the application will ever be performed, even by a full-system backup that would otherwise cause all application data to be saved via adb. The default value of this attribute is true.
meaning if you set it to true, it doesn't change any behaviour.
The other part is not clear, i suggest, if its different from the original question, ask a new question specifying only that.
Upvotes: 3
Reputation: 4857
You can try create next algorithm:
I use 1-3 points in my apps and it works fine, but its work on any deleting any app.
Upvotes: 0