Clear application user data with ADB in Android

How to clear app data with adb command.

1. adb shell pm clear PACKAGE_NAME

The following command clear the app data in the com.google.android.youtube package.

$ adb shell pm clear com.google.android.youtube
Success

2. How to get a package name from the device

To clear data with this command, you need to know the app`s package name.

The following command prints a list of all packages installed on the device. If your app name and package name are similar, you can find them here.

$ adb shell pm list packages

package:com.google.android.networkstack.tethering
package:com.android.cts.priv.ctsshim
package:com.google.android.youtube
package:com.android.internal.display.cutout.emulation.corner
package:com.google.android.ext.services
package:com.android.internal.display.cutout.emulation.double
package:com.android.providers.telephony
package:com.android.dynsystem
package:com.android.theme.icon.pebble
...

If the package name is not similar to the name of the app, it is not easy to find the package name with the above method.

In this case, you can run the app and guess a similar package name from the activity name of the app executed with the logcat command as follows.

$ adb shell logcat -b events | grep wm_on_re
07-11 14:44:34.246   923   923 I wm_on_resume_called: [152199755,com.android.settings.FallbackHome,RESUME_ACTIVITY]
07-11 14:44:37.114  1045  1045 I wm_on_resume_called: [218164884,com.google.android.apps.nexuslauncher.NexusLauncherActivity,RESUME_ACTIVITY]
07-11 14:49:55.441  4941  4941 I wm_on_resume_called: [224219331,com.google.android.apps.youtube.app.WatchWhileActivity,RESUME_ACTIVITY]

Related Posts

codechachaCopyright ©2019 codechacha