清空联系人数据
2015-12-13 22:11
309 查看
命令:
adb shell
pm 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;
}
adb shell
pm 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;
}
相关文章推荐
- 敏捷开发实战(三)--每日晨会,是否只是摆设?
- rootfs之自动mount U盘
- Title_我有个朋友,前几天去世了
- 简读The Swift Programming Language官方文档--基础篇
- hdu 1269 迷宫城堡(Targin算法)
- 源码生成deb包
- Python基础-元组小结
- 深入浅出JMS(二)--ActiveMQ简单介绍以及安装
- java设计模式(六)--适配器模式
- 顺序表的查找
- iOS开发57-Github关联到域名上
- Dijkstra算法 --- 单源最短路
- android中手机定位
- Git 提高命令的可读性
- 无插件Vim编程技巧
- C语言程序练习
- Dialog && PopupWindow
- [hdoj试题]Box of Bricks
- 第三个Sprint冲刺第七天
- 读《世界是数字的》④