Can I automatically delete accounts and sync them on my Android phone?

I am developing a project that should remotely delete accounts and synchronize such as Facebook, Twitter, Dropbox, etc. .. Is it possible to do this through programming? Looking for opinions from you guys ...

Thanks.

+7
source share
1 answer

Yes, this can be done using AccountManager and removeAccount .

First get an instance of AccountManager :

 AccountManager am = AccountManager.get(this); 

Then get a list of all the accounts on the device:

 Account[] accounts = am.getAccounts(); 

Once you have selected the account (s) you want to delete (for this example, we just use the first one), call removeAccount on them:

 if (accounts.length > 0) { Account accountToRemove = accounts[0]; am.removeAccount(accountToRemove, null, null); } 

You can use the 2nd parameter of the removeAccount method to call back after calling the account (deleting the account is an asynchronous operation).

+12
source

All Articles