If you think the Android project adb-idea listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.developerphil.adbidea.adb.command;
/*fromwww.java2s.com*/import com.android.ddmlib.IDevice;
import com.developerphil.adbidea.adb.command.receiver.GenericReceiver;
import com.intellij.openapi.project.Project;
import org.jetbrains.android.facet.AndroidFacet;
import java.util.concurrent.TimeUnit;
importstatic com.developerphil.adbidea.adb.AdbUtil.isAppInstalled;
importstatic com.developerphil.adbidea.ui.NotificationHelper.error;
importstatic com.developerphil.adbidea.ui.NotificationHelper.info;
publicclass ClearDataCommand implements Command {
@Override
publicboolean run(Project project, IDevice device, AndroidFacet facet, String packageName) {
try {
if (isAppInstalled(device, packageName)) {
device.executeShellCommand("pm clear " + packageName, new GenericReceiver(), 5L, TimeUnit.MINUTES);
info(String.format("<b>%s</b> cleared data for app on %s", packageName, device.getName()));
return true;
} else {
error(String.format("<b>%s</b> is not installed on %s", packageName, device.getName()));
}
} catch (Exception e1) {
error("Clear data failed... " + e1.getMessage());
}
return false;
}
}