shadox
shadox

Reputation: 3729

Install APK clear data in Android Studio

When I deploy/debug APK with android studio it always retains data by default. I want to make a new configuration that helps me install without data retention. Any ideas?

And no, I don't want to use gradle at command line everytime.

Upvotes: 1

Views: 2190

Answers (2)

All Іѕ Vаиітy
All Іѕ Vаиітy

Reputation: 26402

You can do duplicate your current run configuration and make it to clear storage

  1. Go to Edit Configruations

enter image description here

  1. Duplicate current congfiguration CTRL+D

enter image description here

  1. Click Clear Storage before deployment

enter image description here

Upvotes: 0

Jagger
Jagger

Reputation: 2562

adb shell pm clear <you.package.name>

Make sure you have adb in command line, otherwise you need to configure adb in your PATH, or go to the directory of your Android SDK.

Copied from my another question but changed the key command: stackoverflow.com/a/25927723/4932305

  1. In Android Studio, click the drop down list to the left of Run button, and select Edit configurations...
  2. Click on app under Android Application, and in General Tab, find the heading 'Before Launch'
  3. Click the + button, select Run external tool, click the + button in the popup window.
  4. Give some name (Eg adb uninstall) and description, and type adb in Program: and shell pm clear <you.package.name> in Parameters:. Make sure that the new item is selected when you click Ok in the popup window.

Upvotes: 3

Related Questions