ContentProvider
在获取本地视频前我们先对Android四大组件之一的ContentProvider进行回顾。
问题1:ContentProvider的作用
用户应用程序之间共享数据(比如我们要获取共享数据系统相册和系统视频),ContentProvider是程序间共享数据的一种协议的定义。 如果我们要将A应用的数据共享给B应用,就需要A应用重写ContentProvider来具体实现这种协议。
ContentProvider的作用简单的说就是定义一种通用的数据暴漏方式。
ContentProvider是一个抽象类,重写该类需要实现的方法如下:
- onCreate():which is called to initialize the provider
- query(Uri, String[], String, String[], String):which returns data to the caller
- insert(Uri, ContentValues):which inserts new data into the content provider
- update(Uri, ContentValues, String, String[]):which updates existing data in the content provider
- delete(Uri, String, String[]):which deletes data from the content provider
- getType(Uri):which returns the MIME type of data in the content provider