detecting the deletion of an android account -


i'm developing android application accounts, sync , content provider. adding account works, syncing , data saved in content provider.

now, when user deletes account using settings, syncing stops, data stays in content provider.

i'd delete it, don't know how catch event of account deletion.

there accountmanager.addonaccountsupdatedlistener(), i've tried add sync service, sync service started sync , stopped. whenever account gets deleted while there no sync, can't caught.

is there best practice on how handle private data when account gets deleted?

first should add onaccountsupdatelistener accountmanager using command:

accountmanager maccountmgr = accountmanager.get(getcontext()); maccountmgr.addonaccountsupdatedlistener(new accountsupdatelistener(), null, false); 

accountsupdatelistener implemented class of onaccountsupdatelistener this:

private class accountsupdatelistener implements onaccountsupdatelistener {     @override     public void onaccountsupdated(account[] accounts) {         account newaccount = null;         (final account account : accounts) {             if (account.type.equals(maccounttype)) {                 newaccount = account;             }         }          if (newaccount == null) {           // account removed, can handle private data , remove want here         }     } } 

onaccountsupdated fired when add account or account removed. can check account type find specified account in accounts array. if doesn't exist removed ! maccounttype account type. e.g maccounttype = "your application name"


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -