标签:
Android studio
在清单文件.xml中配置:
<provider
android:authorities="com.example.com.visitDB.provider"
android:name="com.example.com.content_test.Content_Provider"
android:exported="true"></provider>
name:所定义类的位置;
authorities:主机名,自己随意去(注:最好见名知意);
ContentProvider 类中主要代码:
static
{
matcher.addURI("com.example.com.visitDB.provider","query",1);
matcher.addURI("com.example.com.visitDB.provider","select",2);
matcher.addURI("com.example.com.visitDB.provider","insert",3);
matcher.addURI("com.example.com.visitDB.provider","delete",4);
}
定义Uri接口:
Uri格式:content://主机名/query
MainActivity 主要代码:
ContentValues values = new ContentValues();
利用ContentValues去访问;
标签:
原文地址:http://www.cnblogs.com/guoxiansheng/p/5671511.html