Home | History | Annotate | Download | only in providers
      1 page.title= 
      2 @jd:body
      3 
      4 <div id="qv-wrapper">
      5 <div id="qv">
      6     <h2> </h2>
      7     <ol>
      8   <li><a href="#overview"></a></li>
      9   <li><a href="#manifest"> </a></li>
     10   <li><a href="#calendar"> </a>
     11 <ol>
     12       <li><a href="#query"> </a></li>
     13       <li><a href="#modify-calendar"> </a></li>
     14       <li><a href="#insert-calendar"> </a></li>
     15     </ol>
     16   </li>
     17   <li><a href="#events"> </a>
     18 <ol>
     19       <li><a href="#add-event"> </a></li>
     20       <li><a href="#update-event"> </a></li>
     21       <li><a href="#delete-event"> </a></li>
     22     </ol>
     23   </li>
     24   <li><a href="#attendees"> </a>
     25 <ol>
     26       <li><a href="#add-attendees"> </a></li>
     27     </ol>
     28   </li>
     29   <li><a href="#reminders"> </a>
     30 <ol>
     31       <li><a href="#add-reminders"> </a></li>
     32     </ol>
     33   </li>
     34   <li><a href="#instances"> </a>
     35   <ol>
     36       <li><a href="#query-instances">  </a></li>
     37   </ol></li>
     38   <li><a href="#intents"> </a>
     39   <ol>
     40       <li><a href="#intent-insert">    </a></li>
     41       <li><a href="#intent-edit">    </a></li>
     42       <li><a href="#intent-view">     </a></li>
     43     </ol>
     44   </li>
     45 
     46   <li><a href="#sync-adapter"> </a></li>
     47 </ol>
     48 
     49     <h2> </h2>
     50     <ol>
     51       <li>{@link android.provider.CalendarContract.Calendars}</li>
     52       <li>{@link android.provider.CalendarContract.Events}</li>
     53       <li>{@link android.provider.CalendarContract.Attendees}</li>
     54       <li>{@link android.provider.CalendarContract.Reminders}</li>
     55     </ol>
     56 </div>
     57 </div>
     58 
     59 <p>        . API
     60    , ,    ,
     61 , ,   ..</p>
     62 
     63 
     64 <p>API      ,    . 
     65    ,   .   
     66     API     .   
     67      
     68 <a href="#sync-adapter"> </a>.</p>
     69 
     70 
     71 <p>,      ,   
     72     ,     <a href="#manifest">
     73 </a>.      ,  
     74    ,     <a href="#intents">
     75 </a>.          , 
     76   .       
     77   .       ,
     78          .</p>
     79 
     80 <h2 id="overview"></h2>
     81 
     82 <p><a href="{@docRoot}guide/topics/providers/content-providers.html"> </a>         
     83  .  ,   Android (  )       ,  
     84      .        ,    
     85    .  API   
     86       /     ,  
     87    .</p>
     88 
     89 <p>     URI (  
     90 {@link android.net.Uri}),
     91       .   ,  
     92    ( ),   URI   .  
     93 URI     content://.  
     94  ,      .  
     95    URI     (). 
     96 URI   <code><em>&lt;class&gt;</em>.CONTENT_URI</code>. ,
     97 {@link android.provider.CalendarContract.Events#CONTENT_URI Events.CONTENT_URI}.</p>
     98 
     99 <p> 1       .   
    100    ,      .</p>
    101 
    102 <img src="{@docRoot}images/providers/datamodel.png" alt="Calendar Provider Data Model" />
    103 <p class="img-caption"><strong>1.</strong>    .</p>
    104 
    105 <p>     ,          (Google , Exchange  ..).</p>
    106 
    107 <p> {@link android.provider.CalendarContract}      ,   .      ,  .</p>
    108 
    109 <table>
    110   <tr>
    111     <th> ()</th>
    112     <th></th>
    113   </tr>
    114   <tr>
    115     <td><p>{@link android.provider.CalendarContract.Calendars}</p></td>
    116 
    117     <td>   
    118   .       
    119   , ,  , ,     ..</td>
    120   </tr>
    121   <tr>
    122     <td>{@link android.provider.CalendarContract.Events}</td>
    123 
    124     <td>   
    125   .         
    126 &mdash;,  ,  ,  , 
    127   ..      .   ,
    128        .
    129        {@link android.provider.CalendarContract.AttendeesColumns#EVENT_ID},
    130     {@link android.provider.BaseColumns#_ID}   .</td>
    131 
    132   </tr>
    133   <tr>
    134     <td>{@link android.provider.CalendarContract.Instances}</td>
    135 
    136     <td>      
    137      .     
    138    .     
    139   .       ,
    140     .</td>
    141   </tr>
    142   <tr>
    143     <td>{@link android.provider.CalendarContract.Attendees}</td>
    144 
    145     <td>   
    146    ().       
    147 .         ,
    148    .</td>
    149   </tr>
    150   <tr>
    151     <td>{@link android.provider.CalendarContract.Reminders}</td>
    152 
    153     <td>   
    154    .          .  
    155     .      
    156   
    157   {@link android.provider.CalendarContract.CalendarColumns#MAX_REMINDERS},
    158     , 
    159  .        
    160  ,     .</td>
    161   </tr>
    162 
    163 </table>
    164 
    165 <p>API       .    
    166   ,     ,
    167        .  
    168  ,       API.</p>
    169 
    170 <ul>
    171 
    172 <li><strong>,     .</strong>  ,        ,   <a href="#manifest"></a>. ,           ,     .     ,    Android,         .             
    173    .      .
    174            ,
    175         .   
    176   .      <a href="#intents">
    177 </a>.</p>
    178 
    179 
    180 <li><strong> .</strong>     
    181            .  
    182 {@link android.provider.CalendarContract.Calendars} 
    183 {@link android.provider.CalendarContract.Events} 
    184 ,    .
    185  ,      .   
    186   ,       .   
    187      <a href="#sync-adapter"> </a>.</li>
    188 
    189 </ul>
    190 
    191 
    192 <h2 id="manifest"> </h2>
    193 
    194 <p>   ,        {@link
    195 android.Manifest.permission#READ_CALENDAR}.   
    196    {@link android.Manifest.permission#WRITE_CALENDAR}
    197  ,     :</p>
    198 
    199 <pre>
    200 &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
    201 &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android"...>;
    202     &lt;uses-sdk android:minSdkVersion=&quot;14&quot; /&gt;
    203     &lt;uses-permission android:name=&quot;android.permission.READ_CALENDAR&quot; /&gt;
    204     &lt;uses-permission android:name=&quot;android.permission.WRITE_CALENDAR&quot; /&gt;
    205     ...
    206 &lt;/manifest&gt;
    207 </pre>
    208 
    209 
    210 <h2 id="calendar"> </h2>
    211 
    212 <p>  {@link android.provider.CalendarContract.Calendars}   
    213    .      
    214     ,  <a href="#sync-adapter"> </a>.
    215         
    216 {@link android.provider.CalendarContract.Calendars}.</p>
    217 <table>
    218   <tr>
    219     <th></th>
    220     <th></th>
    221   </tr>
    222   <tr>
    223     <td>{@link android.provider.CalendarContract.Calendars#NAME}</td>
    224     <td> .</td>
    225   </tr>
    226   <tr>
    227     <td>{@link android.provider.CalendarContract.Calendars#CALENDAR_DISPLAY_NAME}</td>
    228     <td>  ,    .</td>
    229   </tr>
    230   <tr>
    231     <td>{@link android.provider.CalendarContract.Calendars#VISIBLE}</td>
    232 
    233     <td> , ,     . 
    234 0   ,  ,  
    235  ,  .   1   ,  ,  
    236  , .         {@link
    237 android.provider.CalendarContract.Instances}.</td>
    238 
    239 
    240   </tr>
    241   <tr>
    242     <td>{@link android.provider.CalendarContract.CalendarColumns#SYNC_EVENTS}</td>
    243 
    244     <td> , ,          
    245  .  0 ,       
    246       .   1 ,      
    247       .</td>
    248   </tr>
    249 </table>
    250 
    251 <h3 id="query"> </h3>
    252 
    253 <p>   ,   , 
    254   .          
    255    ( ).       
    256 ,    .     
    257 <a href="{@docRoot}guide/components/loaders.html"></a>.     
    258  ,      ,      {@link android.content.AsyncQueryHandler}.
    259 </p>
    260 
    261 
    262 <pre>
    263 // Projection array. Creating indices for this array instead of doing
    264 // dynamic lookups improves performance.
    265 public static final String[] EVENT_PROJECTION = new String[] {
    266     Calendars._ID,                           // 0
    267     Calendars.ACCOUNT_NAME,                  // 1
    268     Calendars.CALENDAR_DISPLAY_NAME,         // 2
    269     Calendars.OWNER_ACCOUNT                  // 3
    270 };
    271 
    272 // The indices for the projection array above.
    273 private static final int PROJECTION_ID_INDEX = 0;
    274 private static final int PROJECTION_ACCOUNT_NAME_INDEX = 1;
    275 private static final int PROJECTION_DISPLAY_NAME_INDEX = 2;
    276 private static final int PROJECTION_OWNER_ACCOUNT_INDEX = 3;</pre>
    277 
    278 
    279 <div class="sidebox-wrapper"> <div class="sidebox"> <h3>   
    280 ACCOUNT_TYPE?</h3> <p>   {@link
    281 android.provider.CalendarContract.Calendars#ACCOUNT_NAME
    282 Calendars.ACCOUNT_NAME}  
    283 
    284 {@link android.provider.CalendarContract.Calendars#ACCOUNT_TYPE Calendars.ACCOUNT_TYPE}.     ,   
    285    ,       <code>ACCOUNT_NAME</code>,  
    286 <code>ACCOUNT_TYPE</code>.  <code>ACCOUNT_TYPE</code>   
    287    ,       
    288 {@link android.accounts.AccountManager}.     ,  {@link
    289 android.provider.CalendarContract#ACCOUNT_TYPE_LOCAL}.    ,
    290      .  {@link
    291 android.provider.CalendarContract#ACCOUNT_TYPE_LOCAL} 
    292 .</p> </div> </div>
    293 
    294 
    295 <p>      .    
    296   .     
    297     : <code>ACCOUNT_NAME</code>
    298  sampleuser (a] google.com, <code>ACCOUNT_TYPE</code>
    299  com.google  <code>OWNER_ACCOUNT</code>
    300  sampleuser (a] google.com.    
    301  ,      ,    <code>OWNER_ACCOUNT</code>.
    302    {@link android.database.Cursor},
    303      ,    
    304 .        
    305    <a href="{@docRoot}guide/topics/providers/content-providers.html"> </a>.</p>
    306 
    307 
    308 <pre>// Run query
    309 Cursor cur = null;
    310 ContentResolver cr = getContentResolver();
    311 Uri uri = Calendars.CONTENT_URI;
    312 String selection = "((" + Calendars.ACCOUNT_NAME + " = ?) AND ("
    313                         + Calendars.ACCOUNT_TYPE + " = ?) AND ("
    314                         + Calendars.OWNER_ACCOUNT + " = ?))";
    315 String[] selectionArgs = new String[] {"sampleuser (a] gmail.com", "com.google",
    316         "sampleuser (a] gmail.com"};
    317 // Submit the query and get a Cursor object back.
    318 cur = cr.query(uri, EVENT_PROJECTION, selection, selectionArgs, null);</pre>
    319 
    320 <p>           .  
    321  ,      ,   
    322    .</p>
    323 
    324 <pre>// Use the cursor to step through the returned records
    325 while (cur.moveToNext()) {
    326     long calID = 0;
    327     String displayName = null;
    328     String accountName = null;
    329     String ownerName = null;
    330 
    331     // Get the field values
    332     calID = cur.getLong(PROJECTION_ID_INDEX);
    333     displayName = cur.getString(PROJECTION_DISPLAY_NAME_INDEX);
    334     accountName = cur.getString(PROJECTION_ACCOUNT_NAME_INDEX);
    335     ownerName = cur.getString(PROJECTION_OWNER_ACCOUNT_INDEX);
    336 
    337     // Do something with the values...
    338 
    339    ...
    340 }
    341 </pre>
    342 
    343 <h3 id="modify-calendar"> </h3>
    344 
    345 <p>  ,   {@link
    346 android.provider.BaseColumns#_ID} :    ,
    347   URI
    348 
    349 ({@link android.content.ContentUris#withAppendedId(android.net.Uri,long) withAppendedId()}),
    350      . 
    351    <code>&quot;_id=?&quot;</code>,   
    352 <code>selectionArg</code>   {@link
    353 android.provider.BaseColumns#_ID} .
    354         URI.    
    355     
    356 
    357 ({@link android.content.ContentUris#withAppendedId(android.net.Uri,long) withAppendedId()}):</p>
    358 
    359 <pre>private static final String DEBUG_TAG = "MyActivity";
    360 ...
    361 long calID = 2;
    362 ContentValues values = new ContentValues();
    363 // The new display name for the calendar
    364 values.put(Calendars.CALENDAR_DISPLAY_NAME, &quot;Trevor's Calendar&quot;);
    365 Uri updateUri = ContentUris.withAppendedId(Calendars.CONTENT_URI, calID);
    366 int rows = getContentResolver().update(updateUri, values, null, null);
    367 Log.i(DEBUG_TAG, &quot;Rows updated: &quot; + rows);</pre>
    368 
    369 <h3 id="insert-calendar"> </h2>
    370 
    371 <p>       , 
    372        .   
    373        ,     . 
    374     ,    
    375          {@link
    376 android.provider.CalendarContract.SyncColumns#ACCOUNT_TYPE}  {@link
    377 android.provider.CalendarContract#ACCOUNT_TYPE_LOCAL}.
    378 {@link android.provider.CalendarContract#ACCOUNT_TYPE_LOCAL}
    379       ,   
    380   .       .  
    381       <a href="#sync-adapter"> </a>.</p>
    382 
    383 <h2 id="events"> </h2>
    384 
    385 <p>  {@link android.provider.CalendarContract.Events}   
    386    .    ,    ,
    387  <a href="#manifest"> </a>
    388     {@link android.Manifest.permission#WRITE_CALENDAR}.</p>
    389 
    390 <p>          , 
    391  .          {@link
    392 android.provider.CalendarContract.Events}.</p>
    393 
    394 <table>
    395   <tr>
    396     <th></th>
    397     <th></th>
    398   </tr>
    399   <tr>
    400     <td>{@link android.provider.CalendarContract.EventsColumns#CALENDAR_ID}</td>
    401     <td>{@link android.provider.BaseColumns#_ID} ,    .</td>
    402   </tr>
    403   <tr>
    404     <td>{@link android.provider.CalendarContract.EventsColumns#ORGANIZER}</td>
    405     <td> .   () .</td>
    406   </tr>
    407   <tr>
    408     <td>{@link android.provider.CalendarContract.EventsColumns#TITLE}</td>
    409     <td> .</td>
    410   </tr>
    411   <tr>
    412     <td>{@link android.provider.CalendarContract.EventsColumns#EVENT_LOCATION}</td>
    413     <td> . </td>
    414   </tr>
    415   <tr>
    416     <td>{@link android.provider.CalendarContract.EventsColumns#DESCRIPTION}</td>
    417     <td> .</td>
    418   </tr>
    419   <tr>
    420     <td>{@link android.provider.CalendarContract.EventsColumns#DTSTART}</td>
    421     <td>    UTC ( )   . </td>
    422   </tr>
    423   <tr>
    424     <td>{@link android.provider.CalendarContract.EventsColumns#DTEND}</td>
    425     <td>    UTC ( )   . </td>
    426   </tr>
    427   <tr>
    428     <td>{@link android.provider.CalendarContract.EventsColumns#EVENT_TIMEZONE}</td>
    429     <td>  .</td>
    430   </tr>
    431   <tr>
    432     <td>{@link android.provider.CalendarContract.EventsColumns#EVENT_END_TIMEZONE}</td>
    433     <td>     .</td>
    434   </tr>
    435   <tr>
    436     <td>{@link android.provider.CalendarContract.EventsColumns#DURATION}</td>
    437 
    438     <td>    <a href="http://tools.ietf.org/html/rfc5545#section-3.8.2.5">RFC5545</a>.
    439 ,  <code>&quot;PT1H&quot;</code> ,  
    440    ,   <code>&quot;P2W&quot;</code>   
    441  2. </td>
    442 
    443 
    444   </tr>
    445   <tr>
    446     <td>{@link android.provider.CalendarContract.EventsColumns#ALL_DAY}</td>
    447 
    448     <td>1 ,       
    449   . 0   ,    ,   
    450        .</td>
    451 
    452 
    453   </tr>
    454 
    455 
    456   <tr>
    457     <td>{@link android.provider.CalendarContract.EventsColumns#RRULE}</td>
    458 
    459     <td>    . ,
    460 <code>&quot;FREQ=WEEKLY;COUNT=10;WKST=SU&quot;</code>.  
    461    <a href="http://tools.ietf.org/html/rfc5545#section-3.8.5.3"></a>.</td>
    462 
    463   </tr>
    464 
    465   <tr>
    466     <td>{@link android.provider.CalendarContract.EventsColumns#RDATE}</td>
    467     <td>  .
    468  {@link android.provider.CalendarContract.EventsColumns#RDATE}
    469    {@link android.provider.CalendarContract.EventsColumns#RRULE}
    470    
    471  .     <a href="http://tools.ietf.org/html/rfc5545#section-3.8.5.2"> RFC5545</a>.</td>
    472 </tr>
    473 
    474   <tr>
    475     <td>{@link android.provider.CalendarContract.EventsColumns#AVAILABILITY}</td>
    476 
    477     <td>        ,
    478    . </td>
    479 
    480   </tr>
    481   <tr>
    482     <td>{@link android.provider.CalendarContract.EventsColumns#GUESTS_CAN_MODIFY}</td>
    483     <td>,       . </td>
    484   </tr>
    485   <tr>
    486     <td>{@link android.provider.CalendarContract.EventsColumns#GUESTS_CAN_INVITE_OTHERS}</td>
    487     <td>,      . </td>
    488   </tr>
    489   <tr>
    490     <td>{@link android.provider.CalendarContract.EventsColumns#GUESTS_CAN_SEE_GUESTS}</td>
    491     <td>,      .</td>
    492   </tr>
    493 </table>
    494 
    495 <h3 id="add-event"> </h3>
    496 
    497 <p>     ,    
    498 {@link android.content.Intent#ACTION_INSERT INSERT},     <a href="#intent-insert">    </a>.  
    499      .       ,  
    500 .</p>
    501 
    502 
    503 <p>  ,       . </p>
    504 <ul>
    505 
    506   <li>  {@link
    507 android.provider.CalendarContract.EventsColumns#CALENDAR_ID}  {@link
    508 android.provider.CalendarContract.EventsColumns#DTSTART}.</li>
    509 
    510 <li>  {@link
    511 android.provider.CalendarContract.EventsColumns#EVENT_TIMEZONE}.   
    512      ,   {@link
    513 java.util.TimeZone#getAvailableIDs()}.  ,      
    514      {@link
    515 android.content.Intent#ACTION_INSERT INSERT},     <a href="#intent-insert">    </a>,&mdash;  
    516      .</li>
    517 
    518   <li>     {@link
    519 android.provider.CalendarContract.EventsColumns#DTEND}. </li>
    520 
    521 
    522   <li>     {@link
    523 android.provider.CalendarContract.EventsColumns#DURATION}    {@link
    524 android.provider.CalendarContract.EventsColumns#RRULE}  {@link
    525 android.provider.CalendarContract.EventsColumns#RDATE}.  ,      
    526      {@link
    527 android.content.Intent#ACTION_INSERT INSERT},     <a href="#intent-insert">    </a>,&mdash;  
    528    {@link
    529 android.provider.CalendarContract.EventsColumns#RRULE}    {@link android.provider.CalendarContract.EventsColumns#DTSTART}  {@link android.provider.CalendarContract.EventsColumns#DTEND};  ,  
    530       .</li>
    531 
    532 </ul>
    533 
    534 <p>    .       
    535  .          
    536  ,      .      
    537 {@link android.content.AsyncQueryHandler}.</p>
    538 
    539 
    540 <pre>
    541 long calID = 3;
    542 long startMillis = 0;
    543 long endMillis = 0;
    544 Calendar beginTime = Calendar.getInstance();
    545 beginTime.set(2012, 9, 14, 7, 30);
    546 startMillis = beginTime.getTimeInMillis();
    547 Calendar endTime = Calendar.getInstance();
    548 endTime.set(2012, 9, 14, 8, 45);
    549 endMillis = endTime.getTimeInMillis();
    550 ...
    551 
    552 ContentResolver cr = getContentResolver();
    553 ContentValues values = new ContentValues();
    554 values.put(Events.DTSTART, startMillis);
    555 values.put(Events.DTEND, endMillis);
    556 values.put(Events.TITLE, &quot;Jazzercise&quot;);
    557 values.put(Events.DESCRIPTION, &quot;Group workout&quot;);
    558 values.put(Events.CALENDAR_ID, calID);
    559 values.put(Events.EVENT_TIMEZONE, "America/Los_Angeles");
    560 Uri uri = cr.insert(Events.CONTENT_URI, values);
    561 
    562 // get the event ID that is the last element in the Uri
    563 long eventID = Long.parseLong(uri.getLastPathSegment());
    564 //
    565 // ... do something with event ID
    566 //
    567 //</pre>
    568 
    569 <p class="note"><strong>.</strong>  ,      
    570      .       . 
    571         &mdash; ,    
    572   .</p>
    573 
    574 
    575 <h3 id="update-event"> </h3>
    576 
    577 <p>        ,    
    578 {@link android.content.Intent#ACTION_EDIT EDIT},    
    579 <a href="#intent-edit">    </a>.
    580        .  
    581 ,  
    582 <code>_ID</code> :    ,   URI({@link
    583 android.content.ContentUris#withAppendedId(android.net.Uri,long) withAppendedId()}),
    584      . 
    585    <code>&quot;_id=?&quot;</code>,   
    586 <code>selectionArg</code>   <code>_ID</code> .   
    587   .    
    588 .       
    589 
    590 {@link android.content.ContentUris#withAppendedId(android.net.Uri,long) withAppendedId()}:</p>
    591 
    592 
    593 <pre>private static final String DEBUG_TAG = "MyActivity";
    594 ...
    595 long eventID = 188;
    596 ...
    597 ContentResolver cr = getContentResolver();
    598 ContentValues values = new ContentValues();
    599 Uri updateUri = null;
    600 // The new title for the event
    601 values.put(Events.TITLE, &quot;Kickboxing&quot;);
    602 updateUri = ContentUris.withAppendedId(Events.CONTENT_URI, eventID);
    603 int rows = getContentResolver().update(updateUri, values, null, null);
    604 Log.i(DEBUG_TAG, &quot;Rows updated: &quot; + rows);  </pre>
    605 
    606 <h3 id="delete-event"> </h3>
    607 
    608 <p>     {@link
    609 android.provider.BaseColumns#_ID},       URI,   
    610  .          .
    611     :      .  
    612     <em>deleted</em>  1.  
    613     ,         
    614  .        
    615         .    
    616      {@link android.provider.BaseColumns#_ID}.</p>
    617 
    618 
    619 <pre>private static final String DEBUG_TAG = "MyActivity";
    620 ...
    621 long eventID = 201;
    622 ...
    623 ContentResolver cr = getContentResolver();
    624 ContentValues values = new ContentValues();
    625 Uri deleteUri = null;
    626 deleteUri = ContentUris.withAppendedId(Events.CONTENT_URI, eventID);
    627 int rows = getContentResolver().delete(deleteUri, null, null);
    628 Log.i(DEBUG_TAG, &quot;Rows deleted: &quot; + rows);
    629 </pre>
    630 
    631 <h2 id="attendees"> </h2>
    632 
    633 <p>    {@link android.provider.CalendarContract.Attendees}
    634      .   
    635 {@link android.provider.CalendarContract.Reminders#query(android.content.ContentResolver, long, java.lang.String[]) query()}
    636     
    637   {@link android.provider.CalendarContract.AttendeesColumns#EVENT_ID}.
    638  {@link android.provider.CalendarContract.AttendeesColumns#EVENT_ID}
    639   {@link
    640 android.provider.BaseColumns#_ID}  .</p>
    641 
    642 <p>   
    643 ,   .         , 
    644 <code>ATTENDEE_NAME</code>.
    645 </p>
    646 
    647 
    648 <table>
    649   <tr>
    650     <th></th>
    651     <th></th>
    652   </tr>
    653   <tr>
    654     <td>{@link android.provider.CalendarContract.AttendeesColumns#EVENT_ID}</td>
    655     <td> .</td>
    656   </tr>
    657   <tr>
    658     <td>{@link android.provider.CalendarContract.AttendeesColumns#ATTENDEE_NAME}</td>
    659     <td> .</td>
    660   </tr>
    661   <tr>
    662     <td>{@link android.provider.CalendarContract.AttendeesColumns#ATTENDEE_EMAIL}</td>
    663     <td> .  .</td>
    664   </tr>
    665   <tr>
    666     <td>{@link android.provider.CalendarContract.AttendeesColumns#ATTENDEE_RELATIONSHIP}</td>
    667     <td><p>   .   :</p>
    668       <ul>
    669         <li>{@link android.provider.CalendarContract.AttendeesColumns#RELATIONSHIP_ATTENDEE}</li>
    670         <li>{@link android.provider.CalendarContract.AttendeesColumns#RELATIONSHIP_NONE}</li>
    671         <li>{@link android.provider.CalendarContract.AttendeesColumns#RELATIONSHIP_ORGANIZER}</li>
    672         <li>{@link android.provider.CalendarContract.AttendeesColumns#RELATIONSHIP_PERFORMER}</li>
    673         <li>{@link android.provider.CalendarContract.AttendeesColumns#RELATIONSHIP_SPEAKER}</li>
    674     </ul>
    675     </td>
    676   </tr>
    677   <tr>
    678     <td>{@link android.provider.CalendarContract.AttendeesColumns#ATTENDEE_TYPE}</td>
    679     <td><p> .   : </p>
    680       <ul>
    681         <li>{@link android.provider.CalendarContract.AttendeesColumns#TYPE_REQUIRED}</li>
    682         <li>{@link android.provider.CalendarContract.AttendeesColumns#TYPE_OPTIONAL}</li>
    683     </ul></td>
    684   </tr>
    685   <tr>
    686     <td>{@link android.provider.CalendarContract.AttendeesColumns#ATTENDEE_STATUS}</td>
    687     <td><p>   .   :</p>
    688       <ul>
    689         <li>{@link android.provider.CalendarContract.AttendeesColumns#ATTENDEE_STATUS_ACCEPTED}</li>
    690         <li>{@link android.provider.CalendarContract.AttendeesColumns#ATTENDEE_STATUS_DECLINED}</li>
    691         <li>{@link android.provider.CalendarContract.AttendeesColumns#ATTENDEE_STATUS_INVITED}</li>
    692         <li>{@link android.provider.CalendarContract.AttendeesColumns#ATTENDEE_STATUS_NONE}</li>
    693         <li>{@link android.provider.CalendarContract.AttendeesColumns#ATTENDEE_STATUS_TENTATIVE}</li>
    694     </ul></td>
    695   </tr>
    696 </table>
    697 
    698 <h3 id="add-attendees"> </h3>
    699 
    700 <p>      .  ,     
    701 
    702 {@link android.provider.CalendarContract.AttendeesColumns#EVENT_ID}.</p>
    703 
    704 <pre>
    705 long eventID = 202;
    706 ...
    707 ContentResolver cr = getContentResolver();
    708 ContentValues values = new ContentValues();
    709 values.put(Attendees.ATTENDEE_NAME, &quot;Trevor&quot;);
    710 values.put(Attendees.ATTENDEE_EMAIL, &quot;trevor (a] example.com&quot;);
    711 values.put(Attendees.ATTENDEE_RELATIONSHIP, Attendees.RELATIONSHIP_ATTENDEE);
    712 values.put(Attendees.ATTENDEE_TYPE, Attendees.TYPE_OPTIONAL);
    713 values.put(Attendees.ATTENDEE_STATUS, Attendees.ATTENDEE_STATUS_INVITED);
    714 values.put(Attendees.EVENT_ID, eventID);
    715 Uri uri = cr.insert(Attendees.CONTENT_URI, values);
    716 </pre>
    717 
    718 <h2 id="reminders"> </h2>
    719 
    720 <p>    {@link android.provider.CalendarContract.Reminders}
    721     .   
    722 {@link android.provider.CalendarContract.Reminders#query(android.content.ContentResolver, long, java.lang.String[]) query()}    
    723  
    724 {@link android.provider.CalendarContract.AttendeesColumns#EVENT_ID}.</p>
    725 
    726 
    727 <p>    ,   .   
    728      .  ,    
    729  ,   ,   {@link
    730 android.provider.CalendarContract.Calendars}.   .
    731   
    732 {@link android.provider.CalendarContract.CalendarColumns#ALLOWED_REMINDERS}.</p>
    733 
    734 
    735 <table>
    736   <tr>
    737     <th></th>
    738     <th></th>
    739   </tr>
    740   <tr>
    741     <td>{@link android.provider.CalendarContract.RemindersColumns#EVENT_ID}</td>
    742     <td> .</td>
    743   </tr>
    744   <tr>
    745     <td>{@link android.provider.CalendarContract.RemindersColumns#MINUTES}</td>
    746     <td>   ( )   .</td>
    747   </tr>
    748   <tr>
    749     <td>{@link android.provider.CalendarContract.RemindersColumns#METHOD}</td>
    750     <td><p> ,   .   :</p>
    751       <ul>
    752         <li>{@link android.provider.CalendarContract.RemindersColumns#METHOD_ALERT}</li>
    753         <li>{@link android.provider.CalendarContract.RemindersColumns#METHOD_DEFAULT}</li>
    754         <li>{@link android.provider.CalendarContract.RemindersColumns#METHOD_EMAIL}</li>
    755         <li>{@link android.provider.CalendarContract.RemindersColumns#METHOD_SMS}</li>
    756     </ul></td>
    757   </tr>
    758 </table>
    759 
    760 <h3 id="add-reminders"> </h3>
    761 
    762 <p>      .    15
    763    .</p>
    764 <pre>
    765 long eventID = 221;
    766 ...
    767 ContentResolver cr = getContentResolver();
    768 ContentValues values = new ContentValues();
    769 values.put(Reminders.MINUTES, 15);
    770 values.put(Reminders.EVENT_ID, eventID);
    771 values.put(Reminders.METHOD, Reminders.METHOD_ALERT);
    772 Uri uri = cr.insert(Reminders.CONTENT_URI, values);</pre>
    773 
    774 <h2 id="instances"> </h2>
    775 
    776 <p> 
    777 {@link android.provider.CalendarContract.Instances}    
    778     .     
    779    .     ;   
    780    . </p>
    781 
    782 <p>      ,     .  ,
    783     
    784 {@link android.provider.CalendarContract.CalendarCache#KEY_TIMEZONE_TYPE}
    785 
    786 {@link android.provider.CalendarContract.CalendarCache#KEY_TIMEZONE_INSTANCES}.</p>
    787 
    788 
    789 <table>
    790   <tr>
    791     <th></th>
    792     <th></th>
    793   </tr>
    794   <tr>
    795     <td>{@link android.provider.CalendarContract.Instances#BEGIN}</td>
    796     <td>     UTC ( ).</td>
    797   </tr>
    798   <tr>
    799     <td>{@link android.provider.CalendarContract.Instances#END}</td>
    800     <td>     UTC ( ).</td>
    801   </tr>
    802   <tr>
    803     <td>{@link android.provider.CalendarContract.Instances#END_DAY}</td>
    804 
    805     <td>        
    806  .
    807 
    808 </td>
    809   </tr>
    810   <tr>
    811     <td>{@link android.provider.CalendarContract.Instances#END_MINUTE}</td>
    812 
    813     <td>  ,      
    814  .</td>
    815 
    816   </tr>
    817   <tr>
    818     <td>{@link android.provider.CalendarContract.Instances#EVENT_ID}</td>
    819     <td><code>_ID</code>    .</td>
    820   </tr>
    821     <tr>
    822     <td>{@link android.provider.CalendarContract.Instances#START_DAY}</td>
    823     <td>          .
    824  </td>
    825   </tr>
    826   <tr>
    827     <td>{@link android.provider.CalendarContract.Instances#START_MINUTE}</td>
    828 
    829     <td>  ,      
    830  .
    831 </td>
    832 
    833   </tr>
    834 
    835 </table>
    836 
    837 <h3 id="query-instances">  </h3>
    838 
    839 <p>   ,       
    840 URI.    {@link android.provider.CalendarContract.Instances}
    841     {@link
    842 android.provider.CalendarContract.EventsColumns#TITLE}   
    843  {@link android.provider.CalendarContract.EventsColumns}.
    844  , {@link
    845 android.provider.CalendarContract.EventsColumns#TITLE}
    846      ,      {@link
    847 android.provider.CalendarContract.Instances}   .</p>
    848 
    849 <pre>
    850 private static final String DEBUG_TAG = "MyActivity";
    851 public static final String[] INSTANCE_PROJECTION = new String[] {
    852     Instances.EVENT_ID,      // 0
    853     Instances.BEGIN,         // 1
    854     Instances.TITLE          // 2
    855   };
    856 
    857 // The indices for the projection array above.
    858 private static final int PROJECTION_ID_INDEX = 0;
    859 private static final int PROJECTION_BEGIN_INDEX = 1;
    860 private static final int PROJECTION_TITLE_INDEX = 2;
    861 ...
    862 
    863 // Specify the date range you want to search for recurring
    864 // event instances
    865 Calendar beginTime = Calendar.getInstance();
    866 beginTime.set(2011, 9, 23, 8, 0);
    867 long startMillis = beginTime.getTimeInMillis();
    868 Calendar endTime = Calendar.getInstance();
    869 endTime.set(2011, 10, 24, 8, 0);
    870 long endMillis = endTime.getTimeInMillis();
    871 
    872 Cursor cur = null;
    873 ContentResolver cr = getContentResolver();
    874 
    875 // The ID of the recurring event whose instances you are searching
    876 // for in the Instances table
    877 String selection = Instances.EVENT_ID + " = ?";
    878 String[] selectionArgs = new String[] {"207"};
    879 
    880 // Construct the query with the desired date range.
    881 Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
    882 ContentUris.appendId(builder, startMillis);
    883 ContentUris.appendId(builder, endMillis);
    884 
    885 // Submit the query
    886 cur =  cr.query(builder.build(),
    887     INSTANCE_PROJECTION,
    888     selection,
    889     selectionArgs,
    890     null);
    891 
    892 while (cur.moveToNext()) {
    893     String title = null;
    894     long eventID = 0;
    895     long beginVal = 0;
    896 
    897     // Get the field values
    898     eventID = cur.getLong(PROJECTION_ID_INDEX);
    899     beginVal = cur.getLong(PROJECTION_BEGIN_INDEX);
    900     title = cur.getString(PROJECTION_TITLE_INDEX);
    901 
    902     // Do something with the values.
    903     Log.i(DEBUG_TAG, "Event:  " + title);
    904     Calendar calendar = Calendar.getInstance();
    905     calendar.setTimeInMillis(beginVal);
    906     DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
    907     Log.i(DEBUG_TAG, "Date: " + formatter.format(calendar.getTime()));
    908     }
    909  }</pre>
    910 
    911 <h2 id="intents"> </h2>
    912 <p>     <a href="#manifest"></a>      .     ,    Android,         .     ,   .</p>
    913 <table>
    914   <tr>
    915     <th></th>
    916     <th>URI</th>
    917 
    918     <th></th>
    919     <th> </th>
    920   </tr>
    921   <tr>
    922     <td><br>
    923     {@link android.content.Intent#ACTION_VIEW VIEW} <br></td>
    924     <td><p><code>content://com.android.calendar/time/&lt;ms_since_epoch&gt;</code></p>
    925       URI    
    926 {@link android.provider.CalendarContract#CONTENT_URI CalendarContract.CONTENT_URI}.
    927        <a href="{@docRoot}guide/topics/providers/calendar-provider.html#intent-view">     </a>.
    928 
    929     </td>
    930     <td>   ,   <code>&lt;ms_since_epoch&gt;</code>.</td>
    931     <td>.</td>
    932   </tr>
    933   <tr>
    934     <td><p>{@link android.content.Intent#ACTION_VIEW VIEW} </p>
    935 
    936      </td>
    937     <td><p><code>content://com.android.calendar/events/&lt;event_id&gt;</code></p>
    938 
    939       URI    
    940 {@link android.provider.CalendarContract.Events#CONTENT_URI Events.CONTENT_URI}.
    941        <a href="{@docRoot}guide/topics/providers/calendar-provider.html#intent-view">     </a>.
    942 
    943     </td>
    944     <td> ,    <code>&lt;event_id&gt;</code>.</td>
    945 
    946     <td>{@link android.provider.CalendarContract#EXTRA_EVENT_BEGIN_TIME CalendarContract.EXTRA_EVENT_BEGIN_TIME}<br>
    947       <br>
    948       <br>
    949     {@link android.provider.CalendarContract#EXTRA_EVENT_END_TIME CalendarContract.EXTRA_EVENT_END_TIME}</td>
    950   </tr>
    951 
    952   <tr>
    953     <td>{@link android.content.Intent#ACTION_EDIT EDIT} </td>
    954     <td><p><code>content://com.android.calendar/events/&lt;event_id&gt;</code></p>
    955 
    956     URI    
    957 {@link android.provider.CalendarContract.Events#CONTENT_URI Events.CONTENT_URI}.
    958        <a href="{@docRoot}guide/topics/providers/calendar-provider.html#intent-edit">    </a>.
    959 
    960 
    961     </td>
    962     <td> ,    <code>&lt;event_id&gt;</code>.</td>
    963 
    964     <td>{@link android.provider.CalendarContract#EXTRA_EVENT_BEGIN_TIME CalendarContract.EXTRA_EVENT_BEGIN_TIME}<br>
    965       <br>
    966       <br>
    967     {@link android.provider.CalendarContract#EXTRA_EVENT_END_TIME CalendarContract.EXTRA_EVENT_END_TIME}</td>
    968   </tr>
    969 
    970   <tr>
    971     <td>{@link android.content.Intent#ACTION_EDIT EDIT} <br>
    972     <br>
    973     {@link android.content.Intent#ACTION_INSERT INSERT} </td>
    974     <td><p><code>content://com.android.calendar/events</code></p>
    975 
    976      URI    
    977 {@link android.provider.CalendarContract.Events#CONTENT_URI Events.CONTENT_URI}.
    978        <a href="{@docRoot}guide/topics/providers/calendar-provider.html#intent-insert">    </a>.
    979 
    980     </td>
    981 
    982     <td> .</td>
    983     <td>   ,    .</td>
    984   </tr>
    985 </table>
    986 
    987 <p>      ,    .
    988 </p>
    989 <table>
    990   <tr>
    991     <th>  </th>
    992     <th></th>
    993   </tr>
    994   <tr>
    995     <td>{@link android.provider.CalendarContract.EventsColumns#TITLE Events.TITLE}</td>
    996     <td> .</td>
    997   </tr>
    998   <tr>
    999 
   1000     <td>{@link android.provider.CalendarContract#EXTRA_EVENT_BEGIN_TIME
   1001 CalendarContract.EXTRA_EVENT_BEGIN_TIME}</td>
   1002     <td>   ( )  .</td>
   1003   </tr>
   1004   <tr>
   1005     <td>{@link android.provider.CalendarContract#EXTRA_EVENT_END_TIME
   1006 CalendarContract.EXTRA_EVENT_END_TIME}</td>
   1007 
   1008     <td>   ( )  .</td>
   1009   </tr>
   1010   <tr>
   1011     <td>{@link android.provider.CalendarContract#EXTRA_EVENT_ALL_DAY
   1012 CalendarContract.EXTRA_EVENT_ALL_DAY}</td>
   1013 
   1014     <td> , ,      .   
   1015 <code>true</code>  <code>false</code>.</td> </tr>
   1016   <tr>
   1017     <td>{@link android.provider.CalendarContract.EventsColumns#EVENT_LOCATION
   1018 Events.EVENT_LOCATION}</td>
   1019 
   1020     <td>  .</td>
   1021   </tr>
   1022   <tr>
   1023     <td>{@link android.provider.CalendarContract.EventsColumns#DESCRIPTION
   1024 Events.DESCRIPTION}</td>
   1025 
   1026     <td> .</td>
   1027   </tr>
   1028   <tr>
   1029     <td>
   1030     {@link android.content.Intent#EXTRA_EMAIL Intent.EXTRA_EMAIL}</td>
   1031     <td> .   ( ).</td>
   1032   </tr>
   1033   <tr>
   1034     <td>
   1035     {@link android.provider.CalendarContract.EventsColumns#RRULE Events.RRULE}</td>
   1036     <td>   .</td>
   1037   </tr>
   1038   <tr>
   1039     <td>
   1040     {@link android.provider.CalendarContract.EventsColumns#ACCESS_LEVEL
   1041 Events.ACCESS_LEVEL}</td>
   1042 
   1043     <td>  ,      .</td>
   1044   </tr>
   1045   <tr>
   1046     <td>{@link android.provider.CalendarContract.EventsColumns#AVAILABILITY
   1047 Events.AVAILABILITY}</td>
   1048 
   1049     <td>        ,   .</td>
   1050 
   1051 </table>
   1052 <p>       .</p>
   1053 
   1054 
   1055 <h3 id="intent-insert">    </h3>
   1056 
   1057 <p>   {@link android.content.Intent#ACTION_INSERT INSERT}
   1058           .
   1059    <a href="#manifest"> </a>       {@link
   1060 android.Manifest.permission#WRITE_CALENDAR}.</p>
   1061 
   1062 
   1063 <p>    ,     ,  
   1064       .  {@link
   1065 android.content.Intent#ACTION_INSERT INSERT}   
   1066           .   
   1067   ,       
   1068 .</p>
   1069 
   1070 
   1071 
   1072 <p>   ,    192012.  ,    
   1073 7:30  8:30.     ,    .</p>
   1074 
   1075 <ul>
   1076   <li>  URI   
   1077 {@link android.provider.CalendarContract.Events#CONTENT_URI Events.CONTENT_URI}.</li>
   1078 
   1079   <li>     {@link
   1080 android.provider.CalendarContract#EXTRA_EVENT_BEGIN_TIME
   1081 CalendarContract.EXTRA_EVENT_BEGIN_TIME}  {@link
   1082 android.provider.CalendarContract#EXTRA_EVENT_END_TIME
   1083 CalendarContract.EXTRA_EVENT_END_TIME}     
   1084    .        UTC    
   1085 .</li>
   1086 
   1087   <li>     {@link android.content.Intent#EXTRA_EMAIL Intent.EXTRA_EMAIL}
   1088    ,   (  .).</li>
   1089 
   1090 </ul>
   1091 <pre>
   1092 Calendar beginTime = Calendar.getInstance();
   1093 beginTime.set(2012, 0, 19, 7, 30);
   1094 Calendar endTime = Calendar.getInstance();
   1095 endTime.set(2012, 0, 19, 8, 30);
   1096 Intent intent = new Intent(Intent.ACTION_INSERT)
   1097         .setData(Events.CONTENT_URI)
   1098         .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis())
   1099         .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis())
   1100         .putExtra(Events.TITLE, &quot;Yoga&quot;)
   1101         .putExtra(Events.DESCRIPTION, &quot;Group class&quot;)
   1102         .putExtra(Events.EVENT_LOCATION, &quot;The gym&quot;)
   1103         .putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY)
   1104         .putExtra(Intent.EXTRA_EMAIL, &quot;rowan (a] example.com,trevor (a] example.com&quot;);
   1105 startActivity(intent);
   1106 </pre>
   1107 
   1108 <h3 id="intent-edit">    </h3>
   1109 
   1110 <p>   ,     <a href="#update-event"> </a>.   {@link
   1111 android.content.Intent#ACTION_EDIT EDIT} ,
   1112    ,      .
   1113         
   1114   .</p> <p>   ,  
   1115             .</p>
   1116 
   1117 
   1118 <pre>long eventID = 208;
   1119 Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, eventID);
   1120 Intent intent = new Intent(Intent.ACTION_EDIT)
   1121     .setData(uri)
   1122     .putExtra(Events.TITLE, &quot;My New Title&quot;);
   1123 startActivity(intent);</pre>
   1124 
   1125 <h3 id="intent-view">     </h3>
   1126 <p>     {@link android.content.Intent#ACTION_VIEW VIEW}   :</p>
   1127 <ul>
   1128   <li>     .</li>
   1129   <li> .</li>
   1130 
   1131 </ul>
   1132 <p>        .</p>
   1133 <pre>// A date-time specified in milliseconds since the epoch.
   1134 long startMillis;
   1135 ...
   1136 Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
   1137 builder.appendPath(&quot;time&quot;);
   1138 ContentUris.appendId(builder, startMillis);
   1139 Intent intent = new Intent(Intent.ACTION_VIEW)
   1140     .setData(builder.build());
   1141 startActivity(intent);</pre>
   1142 
   1143 <p>       .</p>
   1144 <pre>long eventID = 208;
   1145 ...
   1146 Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, eventID);
   1147 Intent intent = new Intent(Intent.ACTION_VIEW)
   1148    .setData(uri);
   1149 startActivity(intent);
   1150 </pre>
   1151 
   1152 
   1153 <h2 id="sync-adapter"> </h2>
   1154 
   1155 
   1156 <p>     ,     
   1157     .</p>
   1158 
   1159 <ul>
   1160   <li>   ,    ,    {@link android.provider.CalendarContract#CALLER_IS_SYNCADAPTER}  <code>true</code>.</li>
   1161 
   1162 
   1163   <li>    {@link
   1164 android.provider.CalendarContract.SyncColumns#ACCOUNT_NAME}  {@link
   1165 android.provider.CalendarContract.SyncColumns#ACCOUNT_TYPE}      URI. </li>
   1166 
   1167   <li>         ,    .
   1168   ,       ,
   1169   ,  ,   
   1170 .           ,       ,
   1171    ,  ,  ,   ..
   1172        <code>ACCOUNT_NAME</code> 
   1173 <code>ACCOUNT_TYPE</code>.</li> </ul>
   1174 
   1175 <p>  ,   ,   URI      .</p>
   1176 <pre> static Uri asSyncAdapter(Uri uri, String account, String accountType) {
   1177     return uri.buildUpon()
   1178         .appendQueryParameter(android.provider.CalendarContract.CALLER_IS_SYNCADAPTER,&quot;true&quot;)
   1179         .appendQueryParameter(Calendars.ACCOUNT_NAME, account)
   1180         .appendQueryParameter(Calendars.ACCOUNT_TYPE, accountType).build();
   1181  }
   1182 </pre>
   1183 <p>    (     )   , 
   1184 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html">SampleSyncAdapter</a>.
   1185