栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

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

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

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  [--user ] --bind  [--bind ...]
   a content provider URI.
   binds a typed value to a column and is formatted:
  :: where:
   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  [--user ] [--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  [--user ] --bind  [--bind ...] [--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  [--user ] [--projection ] [--where ] [--sort ]
   is a list of colon separated column names and is formatted:
  [:...]
   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  --method  [--arg ]
       [--extra  ...]
   is the name of a provider-defined method
   is an optional string argument
   is like --bind above, typed data of the form :{b,s,i,l,f,d}:

usage: adb shell content read --uri  [--user ]
  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  [--user ]
  Example:
  # Show the mime-type of the URI
  adb shell content gettype --uri content://media/internal/audio/media/



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

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

(一定记得加群:422901085 获取优惠)
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/658287.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号