[ Android 调试技巧 ] 为什么 content update 命令修改设置不生效?

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

[ Android 调试技巧 ] 为什么 content update 命令修改设置不生效?

尊重原创,转载请注明出处!
创作不易,如有帮助请点赞支持~

问题背景

开发以及定位问题的过程中,遇到 ContentProvider 相关的问题时,可以通过 adb shell content 的命令来进行调试。直接执行这个命令会在命令行打印它的用法(只截取了最常用的 updatequery 的说明):

> 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 
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值