[Android]delete data stored in AccountManager via adb

As you know, you can remove local application data via adb command.

$ adb shell am clear your.package.name

The command is very useful to do Android test against release module with uiautomator, Appium an so on. But, if your application use AccountManager provided by Android platform, the command can’t remove the data stored via account manager.

What you can do is…

  1. Uninstall the app and install again.
  2. Remove account via application.

To make faster and more stable some Android test, 2 is better choice. Because installing apks take a lot of time.

So, I developed the simple application. Anyone can remove data via adb command if you install the following application into your target device.

After installing DroidTEstHelper app in your target device, you only do the following broadcast command. Then data which is stored in Account Manager is removed.

$ adb shell am broadcast -a 'DroidTestHelper' --es ACCOUNT_TYPE your.target.account.type

You should replace your.target.account.type to your target account type.

update 24, Feb, 2019 since I saw a lot of page view for this post.

Over Android 6, it does not work because of the security model. You can use this as well as Android 5-, you need to sign the DroidTestHelper with certification which is used for your test target code. This is like .test app to access to test target application via instrumentation.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.