Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: delete account if the user clears application data

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!

like image 218
PX Developer Avatar asked Nov 02 '22 11:11

PX Developer


1 Answers

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();
like image 172
kalyan pvs Avatar answered Nov 11 '22 11:11

kalyan pvs