操作contentprovider时主要会是下面部分的意思的理解..本人有点菜,个人理解后注解的..
- <pre>
- * 要定义一种mine类型用于操作
- * 1 ..For a single record:(单一 纪录结果)
- * vnd.android.cursor.item/vnd.yourcompanyname.contenttype
- * For example, a request for train record 122, like this URI,
- * content://com.example.transportationprovider/trains/122
- * might return this MIME type: (会返回一个MIME类型对象)
- * vnd.android.cursor.item/vnd.example.rail
- * 2..
- * #
- * For multiple records: (返回多个结 果,一个结果集)
- * vnd.android.cursor.dir/vnd.yourcompanyname.contenttype
- * For example, a request for all train records, like the following URI,
- * content://com.example.transportationprovider/trains
- * trains这部分可能还会有部分 如:trains/bus等定义一个特定的类别
- * might return this MIME type:
- * vnd.android.cursor.dir/vnd.example.rail
- * </pre>
- * 实现BaseColumns类会自动得到两个字段,
- * _COUNT,_ID总记录数与编号
- * @author xiangyuan
- * @version 1.0 2010-4-10 下 午10:39:38
- package com.csust.xiangyuan.data;
- import android.net.Uri;
- import android.provider.BaseColumns;
- /**
- * @title contentProvider主要用来进行不同应用程序之间的共享数据库
- * @author xiangyuan
- * @version 1.0 2010-4-10 下午08:49:07
- */
- public final class NotePadModel {
- /**
- * 一个contentProvider对象声明字符串,这个字符串一定要与Mainfest.xml文件中的 <provider
- * android:name="NotePadProvider"
- * android:authorities="com.google.provider.NotePad" /> 中的相对应,用来标识一个共享数据库信息
- */
- private static final String NODPAD_AUTHORY = "com.csust.xiangyuan.notepad";
- public NotePadModel() {
- }
- /**
- * @title 对数据库中各列的描述
- *
- * <pre>
- * 要定义一种mine类型用于操作
- * 1 ..For a single record:(单一纪录结果)
- * vnd.android.cursor.item/vnd.yourcompanyname.contenttype
- * For example, a request for train record 122, like this URI,
- * content://com.example.transportationprovider/trains/122
- * might return this MIME type:(会返回一个MIME类型对象)
- * vnd.android.cursor.item/vnd.example.rail
- * 2..
- * #
- * For multiple records: (返回多个结果,一个结果集)
- * vnd.android.cursor.dir/vnd.yourcompanyname.contenttype
- * For example, a request for all train records, like the following URI,
- * content://com.example.transportationprovider/trains
- * trains这部分可能还会有部分如:trains/bus等定义一个特定的类别
- * might return this MIME type:
- * vnd.android.cursor.dir/vnd.example.rail
- * </pre>
- * 实现BaseColumns类会自动得到两个字段,
- * _COUNT,_ID总记录数与编号
- * @author xiangyuan
- * @version 1.0 2010-4-10 下午10:39:38
- */
- private static final class NoteDataColumn implements BaseColumns {
- /**
- * 定义一个contentProviderUri,其中Uri定义为:"content" + "" + "/" for the table to use
- */
- public static final Uri CONTENT_RUI = Uri.parse("content//" + NODPAD_AUTHORY + "/notes");
- /**
- * 定义一个多个结果集的,MIME类型
- */
- public static final String CONTENT_MULIPLE_TYPE = "vnd.android.cursor.dir/vnd.xiangyuan.note";
- /**
- * 定义一个单一结果的MIME类型
- */
- public static final String CONTENT_SINGLE_TYPE = "vnd.android.cursor.item/vnd.xiangyuan.note";
- /**
- * 定义数据库的排序方式
- */
- public static final String DEFAULT_STORE_ORDER = "modified DESC";
- /**
- * 记事本的标题
- * <P>Type: TEXT</P>
- */
- public static final String NOTE_TITLE = "title";
- /**
- * notepad content
- * <P>Type: TEXT</P>
- */
- public static final String NOTE = "note";
- /**
- * 创建果间
- * Type: INTEGER (long from System.curentTimeMillis())
- */
- public static final String CREATE_TIME = "created";
- /**
- * 修改时间
- * <p>Type: INTEGER (long from System.curentTimeMillis())</p>
- */
- public static final String MODIFIED = "modified";
- }
- }