尊重原创,转载请注明出处!
创作不易,如有帮助请点赞支持~
问题背景
开发以及定位问题的过程中,遇到 ContentProvider 相关的问题时,可以通过 adb shell content 的命令来进行调试。直接执行这个命令会在命令行打印它的用法(只截取了最常用的 update 和 query 的说明):
> adb shell content
usage: adb shell content [subcommand] [options]
usage: adb shell content update --uri <URI> [--user <USER_ID>] [--where <WHERE>]
<WHERE> is a SQL style where clause in quotes (You have to escape single quotes - see example below).
Example:
# Change "new_setting" secure setting to "newer_value".
adb shell content update --uri content://settings/secure --bind value:s:newer_value --where "name='new_setting'"
usage: adb shell content query --uri <URI> [--user <USER_ID>] [--projection <PROJECTION>] [--where <WHERE>] [--sort <SORT_ORDER>]
<PROJECTION> is a list of colon separated column names and is formatted:
<COLUMN_NAME>[:<COLUMN_NAME>...]
<SORT_ORDER> is the order in which rows in the result should be sorted.
Example:
# Select "name" and "value" columns from secure settings where "name" is equal to "new_setting" and sort the result by name in ascending order.
adb shell content query --uri content://settings/secure --projection name:value --where "name='new_setting'" --sort "name ASC"
[ERROR] Unsupported operation: null
其中 query 用法很简单,直接对照实例说明修改一下就行了,比如查询屏幕超时时间:
XXX:/ # content query --uri content://settings/system --projection name:value --where "name='screen_off_timeout'"
Row: 0 name=screen_off_timeout, value=60000
但是执行 update 命令的时候遇到了麻烦,设置不生效:
XXX:/ # content update

本文介绍了解决Android中使用contentupdate命令修改设置时遇到的问题。通过详细分析命令参数和源码,揭示了命令失效的原因,并给出了正确的命令格式。
最低0.47元/天 解锁文章
3万+

被折叠的 条评论
为什么被折叠?



