【问题标题】:adb: Update/rescan contacts without restarting the android deviceadb:更新/重新扫描联系人而不重启安卓设备
【发布时间】:2014-01-21 02:01:47
【问题描述】:

我正在尝试使用以下命令直接通过 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 或类似的命令行工具。

问候, 反刍

【问题讨论】:

    标签: android shell adb


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多