`

Android中Content Provide

阅读更多
一.Conent Provider用来保存和检索数据,并且使应用程序之间相互访问数据成为可能,它是跨应用程序共享数据的唯一方法。
二.Android提供了应用程序之间访问的统一接口,这些接口被定义在ContentProvide中,包括添加,删除,修改和查询等操作。
例:我们要发送一条短信,可能要用到联系人应用程序,从而选择要发送的人。
三.Content Provider的常用方法:
   ContentProvide定义在android.content包下面。定义一个ContentProvide必须实现几个抽象的方法:
  query(uri,String[],String,String[],String)查询
  insert(Uri,ContentBValues)插入
  update(Uri,ContentValues,String,String[])更新
  delete(Uri,String,String)删除
  getType(Uri)获得MIME的数据类型
四.ContentResolver
  我们是在ContentProvide中实现我们实际操作数据的方法的,但是客户端调用时,我们用到了另外一个接口,它就是ContentResolver。ContnetResolver来操作ContentProvider的。
五.1.ContentProvider是通过对象来进行共享数据
   2.一个URI对象必须以"content://"开头,接下来为URI的授权部分,这个部分内容要和androidMainifest.xml配置文件中声明的授权内容一致,后面还有可能数据类型和记录Id。通过URI可以使得ContentResolver知道和那个ContentProvider对应,并且来操作那些表以及那个记录。
content://com.example.transportationprovider/trains//122
六.创建ContentProvide的步骤:
1.创建保存数据的文件或数据库
2.定义一个类继承ContentProvide。实现抽象方法
3.将定义好的ContentProvider在AndroidMainf.xml配置文件中声明。


分享到:
评论

相关推荐

    解决android.support.v4.content.FileProvide找不到的问题

    主要介绍了解决android.support.v4.content.FileProvide找不到的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

    Android.Programming.The.Big.Nerd.Ranch.Guide

    Each chapter and app has been designed and tested to provide the knowledge and experience you need to get started in Android development. Write and run code every step of the way - creating apps that...

    通讯录设计报告加源代码

    通讯录设计报告 C语言编写 VC编译通过 1.课程实习目的 2.课程实习题目描述和要求 2.1 实习题目 2.2实习要求 3.课程实习报告内容 3.1 功能分析和模块划分 3.2 数据管理模块分析 3.3 用户操作模块设计 ...

    McGraw.Hill.Android.A.Programmers.Guide

    Discover how to provide web and chat functions, interact with the phone dialer and GPS devices, and access the latest Google services. You'll also learn how to create custom Content Providers and...

    Expert Android Programming

    Ltd is a company that works primarily in the development of Android applications and Content Management Systems (CMS). We at Androcid are extremely passionate about Android and try to provide the ...

    android sdk 自带 实例(samples)

    A sample application that demonstrates Android's search framework, including how to provide search suggestions for Quick Search Box. Snake An implementation of the classic game "Snake." Soft ...

    Android代码-ByeBurger

    > Hiding on scroll: We wanted to provide as much content as possible on our user’s screens. Consequently, we decided to make the navigation hide on scroll, thus making more room for the content area....

    Android代码-TextJustify-Android

    This library will provide you a way to justify text. It supports both plain text and Spannables. Additionally, the library can auto-hyphentate your displayed content (thanks to @muriloandrade). ...

    Android漫画源码

    This can be used by an Android project to provide access to ActionBar on applications running on API 7+. There is technically no source, but the src folder is necessary to ensure that the build ...

    android contentprovide demo通俗易懂

    android contentprovide demo通俗易懂。增删改查操作,长按删除,实现清空所有数据。

    Android代码-SlidingRootNav

    It doesn't provide you with a drawer builder. Gradle Add this into your dependencies block. compile 'com.yarolegovich:sliding-root-nav:1.0.2' Sample Please see the sample app for a library usage ...

    Wrox.Professional.Android.Application.Development

    * A detailed look at data storage, retrieval, and sharing using preferences, files, databases, and Content Providers. * Instructions for making the most of mobile portability by creating rich map-...

    Android代码-基于 Bottom Sheet 实现的图片选择器,交互效果不错。

    Bottom sheets slide up from the bottom of the screen to reveal more content. If you want pick image from gallery or take picture, this library can help easily. TedBottomPicker provide 3 options: ...

    Android代码-ToolbarPanel

    This library is inspired from Android Drawerlayout, but instead of showing drawer from either left or right this library will provide you function to pull down the toolbar to show a panel which you ...

    Android代码-xpref

    ContentProvider is designed to provide content between multiple applications that means it supported sharing data between multi-process. Use it to wrap the SharedPreferences can make the latter truly ...

    MockDialogInterface.rar_All You Need

    A mock {@link android.content.DialogInterface} class. All methods are non-functional and throw {@link java.lang.UnsupportedOperationException}. Override it to provide the operations that you need.

    Google chrome browser 65.0.3325

    Set language preferences for web content in Settings > Languages Turn on the prompt for simplified view for all supported articles in Settings > Accessibility settings Share and delete downloads more ...

    Mobile Game Development with Unity

    This practical guide shows you how to create beautiful, interactive content for iOS and Android devices with the Unity game engine. Authors Jon Manning and Paris Buttfield-Addison (iOS Swift Game ...

    notepad++_64位.zip

    We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and ...

Global site tag (gtag.js) - Google Analytics