一.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配置文件中声明。
分享到:
相关推荐
1. **Provider类**:继承自android.content.ContentProvider,它是ContentProvider的基类,需要重写其中的生命周期方法,如onCreate()、query()、insert()、update()、delete()等。 2. **UriMatcher**:用于匹配...
主要介绍了解决android.support.v4.content.FileProvide找不到的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
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 ...
通讯录设计报告 C语言编写 VC编译通过 1.课程实习目的 2.课程实习题目描述和要求 2.1 实习题目 2.2实习要求 3.课程实习报告内容 3.1 功能分析和模块划分 3.2 数据管理模块分析 3.3 用户操作模块设计 ...
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...
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开发中,ContentProvider是Android四大组件之一,它扮演着数据共享的角色,允许不同的应用程序之间交换数据。本文将深入浅出地解析Android ContentProvider的基本用法,通过一个"student_contentprovider...
> 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....
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). ...
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系统中,进程间通信(IPC,Inter-Process Communication)是实现不同应用程序之间数据共享与协同工作的重要机制。ContentProvider作为Android四大组件之一,它就是专门为了解决进程间通信而设计的。在这个...
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 ...
* 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开发中,ContentProvider是一种重要的组件,它允许应用程序之间共享数据。ContentProvider构建在Android的URI(统一资源标识符)机制之上,为其他应用提供了一种标准接口来访问存储在SQLite数据库、文件...
- 首先,创建一个类继承自`android.content.ContentProvider`。 - 实现必要的抽象方法,如`onCreate()`、`query()`、`insert()`、`update()`、`delete()`。 - 在`AndroidManifest.xml`中注册ContentProvider,...
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: ...
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 ...
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 ...