Clear the app data quickly

When developing an app, you’ll surely have encountered situations when you need to clean up the data directory. Common examples include: testing some onboarding flow, an upgrade of the database, and so on.

Unfortunately, the flow you’d instinctively go through is really tedious:

Open up the multitasking menu

Long-press the app entry

(on Lollipop+, do it on the icon in the task description; pre-Lollipop, tap “App info” in the popup menu that appears)

(on Lollipop+, do it on the icon in the task description; pre-Lollipop, tap “App info” in the popup menu that appears) Navigate to the storage section of the app details screen, if needed

Tap Clear data

Confirm

Re-open the app

All these steps have to be repeated every. Single. Time. Arrrgh!

What if I told you there’s a better way of doing it?

Awww yisss

Well as it turns out, there’s a really nifty little AS plugin created by my fellow GDE Philippe Breault.

That plugin, called ADB IDEA, adds a few entries to the Tools > Android menu in Android Studio:

The ADB IDEA entries in Android Studio

What we’re looking for here is the ADB Clear App Data and Restart entry. Select that, and the plugin will do all the tedious work for you with just a couple of clicks. It’s way faster and more convenient than doing it by hand on the device!

The restart function in action on Smart Lock demo

How do you install the plugin?

The easiest way is to follow the instructions on the plugin README:

One last protip

Make the whole procedure even faster by using the plugin’s own ADB Operations dialog. Invoke it with Ctrl-Shift-A (or Ctrl-Alt-Shift-A on Linux and Windows). You can then use the awesome partial match capabilities of the IDE to select the action. Just type cr (shorthand for Clear Restart).

Easy peasy!

Or, if you want to save 50% of your keystrokes on the dialog, just use the number for the option you want to use — in this case, 6.