adb shell调试contentprovider相关命令-千里马android framework

93 篇文章 64 订阅
42 篇文章 22 订阅

hi,经常在做android系统应用开发,或者framework时候其实都少不了和contentprovider打交道,这里contentprovider其实也算android四大组件中非常重要的一个组件。经常如果涉及到数据库操作和跨进程一些通信,如果我们需要测试contentprovider写的是否正确,可以 被客户端调用正常主要有2种方法 :
1、自己写一个demo来 专门访问contentprovider方式,这种方式当然是ok的,但是每次需要访问contentprovider接口等 都需要对代码进行修改,编译运行,其实效率 相对比较低

2、使用adb shell相关的命令进行contentprovider的操作访问,这种方式 其实是最为方便的,不需要写任何代码,只需要adb shell几个命令既可以搞定,但是 奈何很多同学又不知道相关命令,所以 这里对相关命令进行 一个详细记录,也方便日后自己查询使用,
这里其实我们完全使用:adb shell content -h就可以看到所有操作细节及案例,非常详细:

usage: adb shell content [subcommand] [options]

usage: adb shell content insert --uri <URI> [--user <USER_ID>] --bind <BINDING> [--bind <BINDING>...]
  <URI> a content provider URI.
  <BINDING> binds a typed value to a column and is formatted:
  <COLUMN_NAME>:<TYPE>:<COLUMN_VALUE> where:
  <TYPE> specifies data type such as:
  b - boolean, s - string, i - integer, l - long, f - float, d - double
  Note: Omit the value for passing an empty string, e.g column:s:
  Example:
  # Add "new_setting" secure setting with value "new_value".
  adb shell content insert --uri content://settings/secure --bind name:s:new_setting --bind value:s:new_value

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 delete --uri <URI> [--user <USER_ID>] --bind <BINDING> [--bind <BINDING>...] [--where <WHERE>]
  Example:
  # Remove "new_setting" secure setting.
  adb shell content delete --uri content://settings/secure --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"

usage: adb shell content call --uri <URI> --method <METHOD> [--arg <ARG>]
       [--extra <BINDING> ...]
  <METHOD> is the name of a provider-defined method
  <ARG> is an optional string argument
  <BINDING> is like --bind above, typed data of the form <KEY>:{b,s,i,l,f,d}:<VAL>

usage: adb shell content read --uri <URI> [--user <USER_ID>]
  Example:
  # cat default ringtone to a file, then pull to host
  adb shell 'content read --uri content://settings/system/ringtone > /mnt/sdcard/tmp.ogg' && adb pull /mnt/sdcard/tmp.ogg

usage: adb shell content gettype --uri <URI> [--user <USER_ID>]
  Example:
  # Show the mime-type of the URI
  adb shell content gettype --uri content://media/internal/audio/media/



csdn在线学习课程,课程咨询答疑和新课信息:QQ交流群:422901085进行课程讨论

android跨进程通信实战视频课程

(一定记得加群:422901085 获取优惠)

执行adb shell dpm set-device-owner com.catchingnow.icebox/.receiver.DPMReceiver命令是为了将Ice Box应用设置为设备的所有者。这个命令会删除已有的设备所有者,并将Ice Box应用设置为新的设备所有者。执行成功后会提示"Success"。然后,你可以重新设置set-device-owner来激活Ice Box应用。\[1\] 在执行这个命令之前,你需要进行以下几个步骤: 1. 格式化手机数据。 2. 安装Ice Box应用。 3. 打开手机的开发者模式,并启用USB调试模式,仅充电模式。 4. 在电脑上使用adb命令行工具,输入adb shell dpm set-device-owner com.catchingnow.icebox/.receiver.DPMReceiver命令。 5. 如果出现激活成功的提示,说明设置成功。\[2\] 如果在设置时出现提示已经存在账号的问题,你可以尝试以下解决方法: 1. 检查手机的设置,删除所有账号。 2. 如果删除账号后问题仍然存在,并显示"java.lang.IllegalStateException: Not allowed to set the device owner because there are already some accounts on the device",你可以尝试以下解决方法。\[3\] #### 引用[.reference_title] - *1* *3* [Notallowedtosetthedevice owner because there are already some accounts on thedevice](https://blog.csdn.net/sinat_26279817/article/details/81047568)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Android11激活冰箱](https://blog.csdn.net/qq_31255557/article/details/112542688)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

千里马学框架

帮助你了,就请我喝杯咖啡

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值