Android Open Source - adb-idea Clear Data Command






From Project

Back to project page adb-idea.

License

The source code is released under:

Apache License

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;
/*from w  ww  . j a  v a2 s  .c om*/
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;

import static com.developerphil.adbidea.adb.AdbUtil.isAppInstalled;
import static com.developerphil.adbidea.ui.NotificationHelper.error;
import static com.developerphil.adbidea.ui.NotificationHelper.info;

public class ClearDataCommand implements Command {

    @Override
    public boolean 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;
    }

}




Java Source Code List

com.developerphil.TestProjectMultiModule.MyActivity.java
com.developerphil.adbidea.action.AdbAction.java
com.developerphil.adbidea.action.ClearDataAction.java
com.developerphil.adbidea.action.ClearDataAndRestartAction.java
com.developerphil.adbidea.action.KillAction.java
com.developerphil.adbidea.action.RestartAction.java
com.developerphil.adbidea.action.StartAction.java
com.developerphil.adbidea.action.UninstallAction.java
com.developerphil.adbidea.adb.AdbFacade.java
com.developerphil.adbidea.adb.AdbUtil.java
com.developerphil.adbidea.adb.command.ClearDataAndRestartCommand.java
com.developerphil.adbidea.adb.command.ClearDataCommand.java
com.developerphil.adbidea.adb.command.CommandList.java
com.developerphil.adbidea.adb.command.Command.java
com.developerphil.adbidea.adb.command.KillCommand.java
com.developerphil.adbidea.adb.command.RestartPackageCommand.java
com.developerphil.adbidea.adb.command.StartDefaultActivityCommand.java
com.developerphil.adbidea.adb.command.UninstallCommand.java
com.developerphil.adbidea.adb.command.receiver.GenericReceiver.java
com.developerphil.adbidea.ui.DeviceChooserDialog.java
com.developerphil.adbidea.ui.ModuleChooserDialogHelper.java
com.developerphil.adbidea.ui.NotificationHelper.java
com.example.SecondModule.MySecondModuleActivity.java
com.example.app.MainActivity.java
com.example.untitled.MyActivity.java
org.joor.ReflectException.java
org.joor.Reflect.java