Question

I have an Android application that uses Accounts to synchronize data with my server. Yesterday I noticed that, if I click Clear Data in Settings->Apps->My App, the application data is removed but the user account isn't. This leads to consistency problems in my server, since suddenly the user's data is restarted without receiving a restart message.

Is there any way to delete the Account when the user clicks Clear Data? Or at least capture the event to be able to send a message to my server.

Thanks!

Was it helpful?

Solution

There is two ways for you to do it..

1.Not allowing the user to clear the data..this can be done by simply mentioning the..

android:manageSpaceActivity=".ActivityOfYourChoice"

in your manifest under application tag..

2.You can deleting the accounts.it can be done using the AccountManager and the removeAccount method.

First get an instance of the AccountManager:

AccountManager am = AccountManager.get(this);

Then get a list of all accounts on the device:

Account[] accounts = am.getAccounts();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top