adb:更新/重新扫描联系人而无需重新启动Android设备

时间:2014-01-21 02:01:48

标签: android shell adb

我正在尝试使用以下命令直接通过db加载联系人。

adb shell rm /data/data/com.android.providers.contacts/databases/contacts2.db
adb pull /data/data/com.android.providers.contacts/databases/contacts2.db <PATH>
adb push <PATH>/contacts2.db /data/data/com.android.providers.contacts/databases/

但是,我必须重新启动设备(尝试使用多个Android手机)才能更新联系人。

有没有办法在不重启设备的情况下从推送/删除的数据库(没有联系人)获取更新的联系人?

由于项目要求,我无法使用任何第三方应用程序。优选的解决方案是通过adb或类似的命令行工具。

此致 Rumit

1 个答案:

答案 0 :(得分:-1)

终于得到了答案。

这是一个4步骤的过程。

# Remove existing contacts from the device
adb shell rm /data/data/com.android.providers.contacts/databases/contacts2.db
# Copy the desired contacts to the device
adb push contacts2.db /data/data/com.android.providers.contacts/databases/
# Kill the contacts app
adb shell kill $(adb shell ps | grep android.process.acore | awk '{ print $2 }')
# Start the contacts app
adb shell am start -W -n CONTACTS_APP_ACTIVITY
相关问题