命令:adb shellpm clean com.android.providers.contacts代码::rootCommand("com.android.contacts");rootCommand("pm clear com.android.providers.contacts"); import java.io.DataOutputStream; /** * 授权root用户权限 * * @param command 要执行的命令 * */ public boolean rootCommand(String command) { Process process = null; DataOutputStream dos = null; try { process = Runtime.getRuntime().exec("su"); dos = new DataOutputStream(process.getOutputStream()); dos.writeBytes(command + "\n"); Toast.makeText(DemoActivity.this, "执行命令成功", 1).show(); dos.writeBytes("exit\n"); dos.flush(); process.waitFor(); } catch (Exception e) { Toast.makeText(DemoActivity.this, "执行命令失败", 1).show(); return false; } finally { try { if (dos != null) { dos.close(); } process.destroy(); } catch (Exception e) { } } return true; }
清空联系人数据
最新推荐文章于 2022-06-02 14:11:28 发布