一般不需要自定义,原因是我们一般是拿第三方提供的数据,跟广播类似
@Overridepublic Uri insert(Uri uri, ContentValues values) { db.insert("person", null, values); return uri;}在清单文件中定义内容提供者的标签,注意必须要有authorities属性,这是内容提供者的主机名,功能类似地址<provider android:name="com.xxx.contentprovider.PersonProvider" android:authorities="com.xxx.person" android:exported="true"></provider>创建一个其他应用,访问自定义的内容提供者,实现对数据库的插入操作public void click(View v){ //得到内容分解器对象 ContentResolver cr = getContentResolver(); ContentValues cv = new ContentValues(); cv.put("name", "小方"); cv.put("phone", 138856); cv.put("money", 3000); //url:内容提供者的主机名 cr.insert(Uri.parse("content://com.xxx.person"), cv);}新闻热点
疑难解答