android中的ContentProvider定义需要操作时用到的东西

操作contentprovider时主要会是下面部分的意思的理解..本人有点菜,个人理解后注解的..

  1.       <pre> 
  2.      *   要定义一种mine类型用于操作 
  3.      * 1 ..For a single record:(单一 纪录结果)  
  4.      *      vnd.android.cursor.item/vnd.yourcompanyname.contenttype 
  5.      * For example, a request for train record 122, like this URI, 
  6.      *  content://com.example.transportationprovider/trains/122 
  7.      * might return this MIME type: (会返回一个MIME类型对象) 
  8.      *      vnd.android.cursor.item/vnd.example.rail 
  9.      * 2.. 
  10.      * # 
  11.      * For multiple records: (返回多个结 果,一个结果集) 
  12.      *       vnd.android.cursor.dir/vnd.yourcompanyname.contenttype 
  13.      * For example, a request for all train records, like the following URI, 
  14.      *       content://com.example.transportationprovider/trains 
  15.      *       trains这部分可能还会有部分 如:trains/bus等定义一个特定的类别 
  16.      * might return this MIME type: 
  17.      *       vnd.android.cursor.dir/vnd.example.rail 
  18.      * </pre> 
  19.      * 实现BaseColumns类会自动得到两个字段, 
  20.      * _COUNT,_ID总记录数与编号 
  21.      * @author xiangyuan 
  22.      * @version 1.0 2010-4-10 下 午10:39:38
Code:
  1. package com.csust.xiangyuan.data;  
  2.   
  3. import android.net.Uri;  
  4. import android.provider.BaseColumns;  
  5.   
  6. /** 
  7.  * @title contentProvider主要用来进行不同应用程序之间的共享数据库 
  8.  * @author xiangyuan 
  9.  * @version 1.0 2010-4-10 下午08:49:07 
  10.  */  
  11. public final class NotePadModel {  
  12.   
  13.     /** 
  14.      * 一个contentProvider对象声明字符串,这个字符串一定要与Mainfest.xml文件中的 <provider 
  15.      * android:name="NotePadProvider" 
  16.      * android:authorities="com.google.provider.NotePad" /> 中的相对应,用来标识一个共享数据库信息 
  17.      */  
  18.     private static final String NODPAD_AUTHORY = "com.csust.xiangyuan.notepad";  
  19.   
  20.     public NotePadModel() {  
  21.     }  
  22.   
  23.     /** 
  24.      * @title 对数据库中各列的描述 
  25.      *  
  26.      *        <pre> 
  27.      *   要定义一种mine类型用于操作 
  28.      * 1 ..For a single record:(单一纪录结果)  
  29.      *      vnd.android.cursor.item/vnd.yourcompanyname.contenttype 
  30.      * For example, a request for train record 122, like this URI, 
  31.      *  content://com.example.transportationprovider/trains/122 
  32.      * might return this MIME type:(会返回一个MIME类型对象) 
  33.      *      vnd.android.cursor.item/vnd.example.rail 
  34.      * 2.. 
  35.      * # 
  36.      * For multiple records: (返回多个结果,一个结果集) 
  37.      *       vnd.android.cursor.dir/vnd.yourcompanyname.contenttype 
  38.      * For example, a request for all train records, like the following URI, 
  39.      *       content://com.example.transportationprovider/trains 
  40.      *       trains这部分可能还会有部分如:trains/bus等定义一个特定的类别 
  41.      * might return this MIME type: 
  42.      *       vnd.android.cursor.dir/vnd.example.rail 
  43.      * </pre> 
  44.      * 实现BaseColumns类会自动得到两个字段, 
  45.      * _COUNT,_ID总记录数与编号 
  46.      * @author xiangyuan 
  47.      * @version 1.0 2010-4-10 下午10:39:38 
  48.      */  
  49.     private static final class NoteDataColumn implements BaseColumns {  
  50.           
  51.         /** 
  52.          * 定义一个contentProviderUri,其中Uri定义为:"content" + "" + "/" for the table to use 
  53.          */  
  54.         public static final Uri CONTENT_RUI = Uri.parse("content//" + NODPAD_AUTHORY + "/notes");  
  55.           
  56.         /** 
  57.          * 定义一个多个结果集的,MIME类型 
  58.          */  
  59.         public static final String CONTENT_MULIPLE_TYPE = "vnd.android.cursor.dir/vnd.xiangyuan.note";  
  60.           
  61.           
  62.         /** 
  63.          * 定义一个单一结果的MIME类型 
  64.          */  
  65.         public static final String CONTENT_SINGLE_TYPE = "vnd.android.cursor.item/vnd.xiangyuan.note";  
  66.           
  67.           
  68.         /** 
  69.          * 定义数据库的排序方式 
  70.          */  
  71.         public static final String DEFAULT_STORE_ORDER = "modified DESC";  
  72.           
  73.         /** 
  74.          * 记事本的标题 
  75.          * <P>Type: TEXT</P> 
  76.          */  
  77.         public static final String NOTE_TITLE = "title";  
  78.         /** 
  79.          * notepad content 
  80.          * <P>Type: TEXT</P> 
  81.          */  
  82.         public static final String NOTE = "note";  
  83.           
  84.         /** 
  85.          * 创建果间 
  86.          * Type: INTEGER (long from System.curentTimeMillis()) 
  87.          */  
  88.         public static final String CREATE_TIME = "created";  
  89.           
  90.         /** 
  91.          * 修改时间 
  92.          * <p>Type: INTEGER (long from System.curentTimeMillis())</p> 
  93.          */  
  94.         public static final String MODIFIED = "modified";  
  95.     }  
  96. }  

 

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值