Cover image: “Starry Night - Dolomites - Italy” by Edoardo Brotto — on flickr

In this series we’ll see a few lesser known tips for improving your productivity in Android Studio and IntelliJ IDEA. These posts won’t be your everyday shortcut list posts; instead, I’ll try to show you how I use some neat IDE features to address issues I encounter in my daily Android development.


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)
  • 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 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!

Smart Lock demo

How do you install the plugin?

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

https://github.com/pbreault/adb-idea#installation

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.


Want to read more?

You can take a look at the other posts in this series.

Thanks to Said Tahsin Dane and the others for proofreading. Thanks to Philippe for the great plugin!