1 page.title= 2 @jd:body 3 <div id="qv-wrapper"> 4 <div id="qv"> 5 6 7 <h2> </h2> 8 <ol> 9 <li> 10 <a href="#DataStorage"> </a> 11 </li> 12 <li> 13 <a href="#ContentURI"> URI </a> 14 </li> 15 <li> 16 <a href="#ContentProvider">ContentProvider </a> 17 <ol> 18 <li> 19 <a href="#RequiredAccess"> </a> 20 </li> 21 <li> 22 <a href="#Query">query() </a> 23 </li> 24 <li> 25 <a href="#Insert">insert() </a> 26 </li> 27 <li> 28 <a href="#Delete">delete() </a> 29 </li> 30 <li> 31 <a href="#Update">update() </a> 32 </li> 33 <li> 34 <a href="#OnCreate">onCreate() </a> 35 </li> 36 </ol> 37 </li> 38 <li> 39 <a href="#MIMETypes"> MIME </a> 40 <ol> 41 <li> 42 <a href="#TableMIMETypes"> MIME </a> 43 </li> 44 <li> 45 <a href="#FileMIMETypes"> MIME </a> 46 </li> 47 </ol> 48 </li> 49 <li> 50 <a href="#ContractClass"> </a> 51 </li> 52 <li> 53 <a href="#Permissions"> </a> 54 </li> 55 <li> 56 <a href="#ProviderElement"><provider> </a> 57 </li> 58 <li> 59 <a href="#Intents"> </a> 60 </li> 61 </ol> 62 <h2>Key </h2> 63 <ol> 64 <li> 65 {@link android.content.ContentProvider} 66 </li> 67 <li> 68 {@link android.database.Cursor} 69 </li> 70 <li> 71 {@link android.net.Uri} 72 </li> 73 </ol> 74 <h2> </h2> 75 <ol> 76 <li> 77 <a href="{@docRoot}resources/samples/NotePad/index.html"> 78 79 </a> 80 </li> 81 </ol> 82 <h2> </h2> 83 <ol> 84 <li> 85 <a href="{@docRoot}guide/topics/providers/content-provider-basics.html"> 86 </a> 87 </li> 88 <li> 89 <a href="{@docRoot}guide/topics/providers/calendar-provider.html"> 90 </a> 91 </li> 92 </ol> 93 </div> 94 </div> 95 96 97 <p> 98 . Android 99 , . 100 101 {@link android.content.ContentProvider} , 102 . , 103 104 . 105 </p> 106 <p> 107 108 API . 109 </p> 110 111 112 <!-- Before You Start Building --> 113 <h2 id="BeforeYouStart"> </h2> 114 <p> 115 . 116 </p> 117 <ol> 118 <li> 119 <strong> </strong>. 120 . 121 <ul> 122 <li> </li> 123 <li> </li> 124 <li> </li> 125 </ul> 126 <p> 127 128 SQLite <em></em> . 129 </p> 130 </li> 131 <li> 132 , 133 <a href="{@docRoot}guide/topics/providers/content-provider-basics.html"> 134 </a> . 135 </li> 136 </ol> 137 <p> 138 , . 139 </p> 140 <ol> 141 <li> 142 . . 143 <dl> 144 <dt> 145 146 </dt> 147 <dd> 148 , 149 . 150 . 151 . 152 </dd> 153 <dt> 154 "" 155 </dt> 156 <dd> 157 , . 158 . 159 . 160 , . 161 SQLite , 162 . Android , 163 <a href="#DataStorage"> 164 </a> . 165 </dd> 166 </dl> 167 </li> 168 <li> 169 {@link android.content.ContentProvider} 170 . Android 171 . 172 <a href="#ContentProvider">ContentProvider </a> . 173 </li> 174 <li> 175 , URI . 176 , 177 . 178 . 179 . . 180 URI 181 <a href="#ContentURI"> URI </a> . 182 183 <a href="#Intents"> </a> . 184 </li> 185 <li> 186 , 187 {@link android.content.AbstractThreadedSyncAdapter} 188 . 189 </li> 190 </ol> 191 192 193 <!-- Designing Data Storage --> 194 <h2 id="DataStorage"> </h2> 195 <p> 196 . 197 . 198 . 199 </p> 200 <p> 201 Android . 202 </p> 203 <ul> 204 <li> 205 Android Android 206 SQLite API . 207 {@link android.database.sqlite.SQLiteOpenHelper} , 208 {@link android.database.sqlite.SQLiteDatabase} 209 . 210 <p> 211 . 212 , 213 . 214 </p> 215 </li> 216 <li> 217 Android API . 218 219 <a href="{@docRoot}guide/topics/data/data-storage.html"> </a> . 220 , 221 . 222 </li> 223 <li> 224 , {@link java.net} 225 {@link android.net} . 226 , . 227 <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html"> 228 </a> . 229 </li> 230 </ul> 231 <h3 id="DataDesign"> 232 233 </h3> 234 <p> 235 . 236 </p> 237 <ul> 238 <li> 239 " " 240 . 241 ( " " ). 242 {@link android.provider.BaseColumns#_ID BaseColumns._ID} . 243 244 {@link android.widget.ListView} 245 <code>_ID</code> . 246 </li> 247 <li> 248 249 250 . , 251 {@link android.content.ContentResolver} . 252 </li> 253 <li> 254 BLOB(Binary Large OBject) 255 . , BLOB 256 <a href="http://code.google.com/p/protobuf"> </a> 257 <a href="http://www.json.org">JSON </a> . 258 <p> 259 BLOB <em> </em> . 260 , , MIME BLOB . 261 262 BLOB MIME . 263 . "" 264 {@link android.provider.ContactsContract.Data} 265 . 266 </p> 267 </li> 268 </ul> 269 <!-- Designing Content URIs --> 270 <h2 id="ContentURI"> URI </h2> 271 <p> 272 <strong> URI</strong> URI. 273 URI ( <strong></strong>) 274 (<strong></strong>) . 275 ID . 276 {@link android.content.ContentProvider} 277 URI . , . 278 </p> 279 <p> 280 URI 281 <a href="{@docRoot}guide/topics/providers/content-provider-basics.html"> 282 </a> . 283 </p> 284 <h3> </h3> 285 <p> 286 , Android . 287 , () 288 . Android , 289 . 290 , Android 291 <code>com.example.<appname></code>, 292 <code>com.example.<appname>.provider</code> . 293 </p> 294 <h3> </h3> 295 <p> 296 URI 297 . , <em>table1</em> 298 <em>table2</em> , 299 URI<code>com.example.<appname>.provider/table1</code> 300 <code>com.example.<appname>.provider/table2</code> . 301 302 , . 303 </p> 304 <h3> URI ID </h3> 305 <p> 306 , URI ID URI 307 . 308 ID <code>_ID</code> , 309 . 310 </p> 311 <p> 312 . 313 {@link android.database.Cursor} 314 {@link android.widget.ListView} {@link android.widget.CursorAdapter} . 315 {@link android.widget.CursorAdapter} 316 {@link android.database.Cursor} <code>_ID</code> . 317 </p> 318 <p> 319 320 UI . {@link android.widget.ListView} {@link android.database.Cursor} , 321 <code>_ID</code> 322 URI , . 323 . 324 </p> 325 <h3> URI </h3> 326 <p> 327 URI API 328 {@link android.content.UriMatcher} 329 . URI "" . 330 URI URI <code>switch</code> . 331 </p> 332 <p> 333 URI URI . 334 </p> 335 <ul> 336 <li> 337 <strong><code>*</code>:</strong> . 338 </li> 339 <li> 340 <strong><code>#</code>:</strong> . 341 </li> 342 </ul> 343 <p> 344 URI . 345 <code>com.example.app.provider</code> 346 URI . 347 </p> 348 <ul> 349 <li> 350 <code>content://com.example.app.provider/table1</code>: <code>table1</code> . 351 </li> 352 <li> 353 <code>content://com.example.app.provider/table2/dataset1</code>: 354 <code>dataset1</code> . 355 </li> 356 <li> 357 <code>content://com.example.app.provider/table2/dataset2</code>: 358 <code>dataset2</code> . 359 </li> 360 <li> 361 <code>content://com.example.app.provider/table3</code>: <code>table3</code> . 362 </li> 363 </ul> 364 <p> 365 ID URI . 366 , <code>table3</code> <code>1</code> 367 <code>content://com.example.app.provider/table3/1</code> . 368 </p> 369 <p> 370 URI . 371 </p> 372 <dl> 373 <dt> 374 <code>content://com.example.app.provider/*</code> 375 </dt> 376 <dd> 377 URI . 378 </dd> 379 <dt> 380 <code>content://com.example.app.provider/table2/*</code>: 381 </dt> 382 <dd> 383 <code>dataset1</code> 384 <code>dataset2</code> URI <code>table1</code> 385 <code>table3</code> URI . 386 </dd> 387 <dt> 388 <code>content://com.example.app.provider/table3/#</code>: 389 <code>table3</code> URI . , 390 <code>6</code> <code>content://com.example.app.provider/table3/6</code> . 391 392 </dt> 393 </dl> 394 <p> 395 {@link android.content.UriMatcher} . 396 URI <code>content://<authority>/<path></code> 397 URI <code>content://<authority>/<path>/<id></code> 398 URI URI . 399 400 </p> 401 <p> 402 {@link android.content.UriMatcher#addURI(String, String, int) addURI()} 403 . {@link android.content.UriMatcher#match(Uri) 404 match()} URI . <code>switch</code> 405 , . 406 </p> 407 <pre class="prettyprint"> 408 public class ExampleProvider extends ContentProvider { 409 ... 410 // Creates a UriMatcher object. 411 private static final UriMatcher sUriMatcher; 412 ... 413 /* 414 * The calls to addURI() go here, for all of the content URI patterns that the provider 415 * should recognize. For this snippet, only the calls for table 3 are shown. 416 */ 417 ... 418 /* 419 * Sets the integer value for multiple rows in table 3 to 1. Notice that no wildcard is used 420 * in the path 421 */ 422 sUriMatcher.addURI("com.example.app.provider", "table3", 1); 423 424 /* 425 * Sets the code for a single row to 2. In this case, the "#" wildcard is 426 * used. "content://com.example.app.provider/table3/3" matches, but 427 * "content://com.example.app.provider/table3 doesn't. 428 */ 429 sUriMatcher.addURI("com.example.app.provider", "table3/#", 2); 430 ... 431 // Implements ContentProvider.query() 432 public Cursor query( 433 Uri uri, 434 String[] projection, 435 String selection, 436 String[] selectionArgs, 437 String sortOrder) { 438 ... 439 /* 440 * Choose the table to query and a sort order based on the code returned for the incoming 441 * URI. Here, too, only the statements for table 3 are shown. 442 */ 443 switch (sUriMatcher.match(uri)) { 444 445 446 // If the incoming URI was for all of table3 447 case 1: 448 449 if (TextUtils.isEmpty(sortOrder)) sortOrder = "_ID ASC"; 450 break; 451 452 // If the incoming URI was for a single row 453 case 2: 454 455 /* 456 * Because this URI was for a single row, the _ID value part is 457 * present. Get the last path segment from the URI; this is the _ID value. 458 * Then, append the value to the WHERE clause for the query 459 */ 460 selection = selection + "_ID = " uri.getLastPathSegment(); 461 break; 462 463 default: 464 ... 465 // If the URI is not recognized, you should do some error handling here. 466 } 467 // call the code to actually do the query 468 } 469 </pre> 470 <p> 471 , {@link android.content.ContentUris} 472 URI <code>id</code> . {@link android.net.Uri} 473 {@link android.net.Uri.Builder} 474 {@link android.net.Uri} . 475 </p> 476 477 <!-- Implementing the ContentProvider class --> 478 <h2 id="ContentProvider">ContentProvider </h2> 479 <p> 480 {@link android.content.ContentProvider} 481 . 482 {@link android.content.ContentResolver} , 483 {@link android.content.ContentProvider} . 484 </p> 485 <h3 id="RequiredAccess"> </h3> 486 <p> 487 {@link android.content.ContentProvider} 488 . 489 ({@link android.content.ContentProvider#onCreate() onCreate()} ) 490 . 491 </p> 492 <dl> 493 <dt> 494 {@link android.content.ContentProvider#query(Uri, String[], String, String[], String) 495 query()} 496 </dt> 497 <dd> 498 . /, . 499 500 {@link android.database.Cursor} . 501 </dd> 502 <dt> 503 {@link android.content.ContentProvider#insert(Uri, ContentValues) insert()} 504 </dt> 505 <dd> 506 . 507 . 508 URI . 509 </dd> 510 <dt> 511 {@link android.content.ContentProvider#update(Uri, ContentValues, String, String[]) 512 update()} 513 </dt> 514 <dd> 515 . 516 . . 517 </dd> 518 <dt> 519 {@link android.content.ContentProvider#delete(Uri, String, String[]) delete()} 520 </dt> 521 <dd> 522 . . 523 . 524 </dd> 525 <dt> 526 {@link android.content.ContentProvider#getType(Uri) getType()} 527 </dt> 528 <dd> 529 URI MIME . 530 <a href="#MIMETypes"> MIME </a> . 531 </dd> 532 <dt> 533 {@link android.content.ContentProvider#onCreate() onCreate()} 534 </dt> 535 <dd> 536 . Android 537 . 538 {@link android.content.ContentResolver} . 539 </dd> 540 </dl> 541 <p> 542 543 {@link android.content.ContentResolver} . 544 </p> 545 <p> 546 . 547 </p> 548 <ul> 549 <li> 550 ({@link android.content.ContentProvider#onCreate() onCreate()} ) 551 , . 552 553 <a href="{@docRoot}guide/components/processes-and-threads.html"> 554 </a> . 555 </li> 556 <li> 557 {@link android.content.ContentProvider#onCreate() 558 onCreate()} . . 559 <a href="#OnCreate">onCreate() </a> 560 . 561 </li> 562 <li> 563 , 564 . 565 . , 566 {@link android.content.ContentProvider#insert(Uri, ContentValues) insert()} 567 0 . 568 </li> 569 </ul> 570 <h3 id="Query">query() </h3> 571 <p> 572 573 {@link android.content.ContentProvider#query(Uri, String[], String, String[], String) 574 ContentProvider.query()} {@link android.database.Cursor} , 575 {@link java.lang.Exception} . SQLite , 576 {@link android.database.sqlite.SQLiteDatabase} <code>query()</code> {@link android.database.Cursor} 577 . 578 , {@link android.database.Cursor#getCount()} 0 579 {@link android.database.Cursor} . 580 <code>null</code> . 581 </p> 582 <p> 583 SQLite , {@link android.database.Cursor} 584 . , {@link android.database.MatrixCursor} 585 {@link java.lang.Object} . 586 {@link android.database.MatrixCursor#addRow(Object[]) addRow()} . 587 </p> 588 <p> 589 Android {@link java.lang.Exception} 590 . Android 591 . 592 </p> 593 <ul> 594 <li> 595 {@link java.lang.IllegalArgumentException} 596 ( URI .) 597 </li> 598 <li> 599 {@link java.lang.NullPointerException} 600 </li> 601 </ul> 602 <h3 id="Insert">insert() </h3> 603 <p> 604 {@link android.content.ContentProvider#insert(Uri, ContentValues) insert()} 605 {@link android.content.ContentValues} 606 . {@link android.content.ContentValues} , 607 . 608 609 </p> 610 <p> 611 URI . 612 <code>_ID</code>( ) URI , 613 {@link android.content.ContentUris#withAppendedId(Uri, long) withAppendedId()} . 614 </p> 615 <h3 id="Delete">delete() </h3> 616 <p> 617 {@link android.content.ContentProvider#delete(Uri, String, String[]) delete()} 618 . 619 , 620 "" . 621 , . 622 </p> 623 <h3 id="Update">Update() </h3> 624 <p> 625 {@link android.content.ContentProvider#update(Uri, ContentValues, String, String[]) 626 update()} {@link android.content.ContentProvider#insert(Uri, ContentValues) insert()} {@link android.content.ContentValues} 627 628 {@link android.content.ContentProvider#delete(Uri, String, String[]) delete()} {@link android.content.ContentProvider#query(Uri, String[], String, String[], String) 629 ContentProvider.query()} <code>selection</code> <code>selectionArgs</code> 630 . 631 . 632 </p> 633 <h3 id="OnCreate">onCreate() </h3> 634 <p> 635 Android {@link android.content.ContentProvider#onCreate() 636 onCreate()} . , 637 . 638 639 {@link android.content.ContentProvider#onCreate() onCreate()} 640 . . 641 642 </p> 643 <p> 644 , SQLite 645 {@link android.content.ContentProvider#onCreate() ContentProvider.onCreate()} 646 {@link android.database.sqlite.SQLiteOpenHelper} , 647 SQL . 648 {@link android.database.sqlite.SQLiteOpenHelper#getWritableDatabase 649 getWritableDatabase()} 650 {@link android.database.sqlite.SQLiteOpenHelper#onCreate(SQLiteDatabase) 651 SQLiteOpenHelper.onCreate()} . 652 </p> 653 <p> 654 655 {@link android.content.ContentProvider#onCreate() ContentProvider.onCreate()} 656 {@link android.database.sqlite.SQLiteOpenHelper#onCreate(SQLiteDatabase) 657 SQLiteOpenHelper.onCreate()} . 658 {@link android.content.ContentProvider#onCreate() ContentProvider.onCreate()} . 659 </p> 660 <pre class="prettyprint"> 661 public class ExampleProvider extends ContentProvider 662 663 /* 664 * Defines a handle to the database helper object. The MainDatabaseHelper class is defined 665 * in a following snippet. 666 */ 667 private MainDatabaseHelper mOpenHelper; 668 669 // Defines the database name 670 private static final String DBNAME = "mydb"; 671 672 // Holds the database object 673 private SQLiteDatabase db; 674 675 public boolean onCreate() { 676 677 /* 678 * Creates a new helper object. This method always returns quickly. 679 * Notice that the database itself isn't created or opened 680 * until SQLiteOpenHelper.getWritableDatabase is called 681 */ 682 mOpenHelper = new MainDatabaseHelper( 683 getContext(), // the application context 684 DBNAME, // the name of the database) 685 null, // uses the default SQLite cursor 686 1 // the version number 687 ); 688 689 return true; 690 } 691 692 ... 693 694 // Implements the provider's insert method 695 public Cursor insert(Uri uri, ContentValues values) { 696 // Insert code here to determine which table to open, handle error-checking, and so forth 697 698 ... 699 700 /* 701 * Gets a writeable database. This will trigger its creation if it doesn't already exist. 702 * 703 */ 704 db = mOpenHelper.getWritableDatabase(); 705 } 706 } 707 </pre> 708 <p> 709 710 {@link android.database.sqlite.SQLiteOpenHelper#onCreate(SQLiteDatabase) 711 SQLiteOpenHelper.onCreate()} . 712 </p> 713 <pre class="prettyprint"> 714 ... 715 // A string that defines the SQL statement for creating a table 716 private static final String SQL_CREATE_MAIN = "CREATE TABLE " + 717 "main " + // Table's name 718 "(" + // The columns in the table 719 " _ID INTEGER PRIMARY KEY, " + 720 " WORD TEXT" 721 " FREQUENCY INTEGER " + 722 " LOCALE TEXT )"; 723 ... 724 /** 725 * Helper class that actually creates and manages the provider's underlying data repository. 726 */ 727 protected static final class MainDatabaseHelper extends SQLiteOpenHelper { 728 729 /* 730 * Instantiates an open helper for the provider's SQLite data repository 731 * Do not do database creation and upgrade here. 732 */ 733 MainDatabaseHelper(Context context) { 734 super(context, DBNAME, null, 1); 735 } 736 737 /* 738 * Creates the data repository. This is called when the provider attempts to open the 739 * repository and SQLite reports that it doesn't exist. 740 */ 741 public void onCreate(SQLiteDatabase db) { 742 743 // Creates the main table 744 db.execSQL(SQL_CREATE_MAIN); 745 } 746 } 747 </pre> 748 749 750 <!-- Implementing ContentProvider MIME Types --> 751 <h2 id="MIMETypes">ContentProvider MIME </h2> 752 <p> 753 {@link android.content.ContentProvider} MIME . 754 </p> 755 <dl> 756 <dt> 757 {@link android.content.ContentProvider#getType(Uri) getType()} 758 </dt> 759 <dd> 760 . 761 </dd> 762 <dt> 763 {@link android.content.ContentProvider#getStreamTypes(Uri, String) getStreamTypes()} 764 </dt> 765 <dd> 766 . 767 </dd> 768 </dl> 769 <h3 id="TableMIMETypes"> MIME </h3> 770 <p> 771 {@link android.content.ContentProvider#getType(Uri) getType()} 772 URI MIME {@link java.lang.String} . 773 {@link android.net.Uri} URI . 774 , URI . 775 776 </p> 777 <p> 778 , HTML JPEG 779 {@link android.content.ContentProvider#getType(Uri) getType()} 780 MIME . 781 <a href="http://www.iana.org/assignments/media-types/index.htm">IANA MIME </a> 782 . 783 </p> 784 <p> 785 URI , 786 {@link android.content.ContentProvider#getType(Uri) getType()} Android MIME 787 MIME . 788 </p> 789 <ul> 790 <li> 791 : <code>vnd</code> 792 </li> 793 <li> 794 : 795 <ul> 796 <li> 797 URI : <code>android.cursor.<strong>item</strong>/</code> 798 </li> 799 <li> 800 URI : <code>android.cursor.<strong>dir</strong>/</code> 801 </li> 802 </ul> 803 </li> 804 <li> 805 : <code>vnd.<name></code>.<code><type></code> 806 <p> 807 <code><name></code> <code><type></code> . 808 <code><name></code> , 809 <code><type></code> URI 810 . <code><name></code> 811 Android . 812 <code><type></code> URI 813 . 814 </p> 815 816 </li> 817 </ul> 818 <p> 819 820 <code>com.example.app.provider</code>, 821 <code>table1</code> , <code>table1</code> MIME . 822 </p> 823 <pre> 824 vnd.android.cursor.<strong>dir</strong>/vnd.com.example.provider.table1 825 </pre> 826 <p> 827 <code>table1</code> , MIME . 828 </p> 829 <pre> 830 vnd.android.cursor.<strong>item</strong>/vnd.com.example.provider.table1 831 </pre> 832 <h3 id="FileMIMETypes"> MIME </h3> 833 <p> 834 , 835 {@link android.content.ContentProvider#getStreamTypes(Uri, String) getStreamTypes()} . 836 URI MIME {@link java.lang.String} . 837 MIME MIME 838 MIME . 839 </p> 840 <p> 841 , <code>.jpg</code>, 842 <code>.png</code> <code>.gif</code> . 843 <code>image/*</code>("" ) {@link android.content.ContentResolver#getStreamTypes(Uri, String) 844 ContentResolver.getStreamTypes()} 845 846 {@link android.content.ContentProvider#getStreamTypes(Uri, String) 847 ContentProvider.getStreamTypes()} . 848 </p> 849 <pre> 850 { "image/jpeg", "image/png", "image/gif"} 851 </pre> 852 <p> 853 <code>.jpg</code> 854 <code>*\/jpeg</code> {@link android.content.ContentResolver#getStreamTypes(Uri, String) 855 ContentResolver.getStreamTypes()} . 856 {@link android.content.ContentProvider#getStreamTypes(Uri, String) 857 ContentProvider.getStreamTypes()} . 858 <pre> 859 {"image/jpeg"} 860 </pre> 861 <p> 862 MIME , 863 {@link android.content.ContentProvider#getStreamTypes(Uri, String) getStreamTypes()} 864 <code>null</code> . 865 </p> 866 867 868 <!-- Implementing a Contract Class --> 869 <h2 id="ContractClass"> </h2> 870 <p> 871 <code>public final</code> , URI, , MIME 872 . 873 URI, 874 875 . 876 </p> 877 <p> 878 . 879 URI . 880 Javadoc . 881 Eclipse 882 Javadoc . 883 </p> 884 <p> 885 886 <code>.jar</code> . 887 </p> 888 <p> 889 {@link android.provider.ContactsContract} 890 . 891 </p> 892 <h2 id="Permissions"> </h2> 893 <p> 894 Android 895 <a href="{@docRoot}guide/topics/security/security.html"> </a> . 896 <a href="{@docRoot}guide/topics/data/data-storage.html"> </a> 897 . 898 . 899 </p> 900 <ul> 901 <li> 902 , 903 . 904 </li> 905 <li> 906 {@link android.database.sqlite.SQLiteDatabase} 907 . 908 </li> 909 <li> 910 <em></em> 911 <em> </em>. 912 . API . 913 </li> 914 <li> 915 SQLite 916 . 917 918 " " " " 919 . 920 "", . 921 </li> 922 </ul> 923 <p> 924 , 925 , SQLite ""(: ) 926 , . 927 </p> 928 <h3> </h3> 929 <p> 930 . 931 . , 932 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html"> 933 <provider></a></code> 934 . , 935 , . 936 </p> 937 <p> 938 939 <code><a href="{@docRoot}guide/topics/manifest/permission-element.html"> 940 <permission></a></code> . 941 942 <code><a href="{@docRoot}guide/topics/manifest/permission-element.html#nm"> 943 android:name</a></code> Java . 944 <code>com.example.app.provider.permission.READ_PROVIDER</code> . 945 946 </p> 947 <p> 948 . 949 . 950 . 951 </p> 952 <dl> 953 <dt> 954 - 955 </dt> 956 <dd> 957 , 958 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html"> 959 <provider></a></code> 960 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#prmsn"> 961 android:permission</a></code> . 962 </dd> 963 <dt> 964 965 </dt> 966 <dd> 967 . 968 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html"> 969 <provider></a></code> <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#rprmsn"> 970 android:readPermission</a></code> 971 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#wprmsn"> 972 android:writePermission</a></code> 973 . 974 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#prmsn"> 975 android:permission</a></code> . 976 </dd> 977 <dt> 978 979 </dt> 980 <dd> 981 URI , / . URI , 982 983 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html"> 984 <provider></a></code> 985 <code><a href="{@docRoot}guide/topics/manifest/path-permission-element.html"> 986 <path-permission></a></code> . URI 987 / , . 988 / . 989 , . 990 </dd> 991 <dt> 992 993 </dt> 994 <dd> 995 . 996 . 997 998 . , 999 "" 1000 . 1001 <p> 1002 . 1003 1004 . , 1005 URI . 1006 URI 1007 . 1008 , . 1009 1010 </p> 1011 <p> 1012 , 1013 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html"> 1014 <provider></a></code> <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#gprmsn"> 1015 android:grantUriPermissions</a></code> 1016 1017 <code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"> 1018 <grant-uri-permission></a></code> 1019 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html"> 1020 <provider></a></code> . , 1021 URI {@link android.content.Context#revokeUriPermission(Uri, int) 1022 Context.revokeUriPermission()} . 1023 URI . 1024 </p> 1025 <p> 1026 . 1027 <code>true</code> 1028 , 1029 . 1030 </p> 1031 <p> 1032 <code>false</code> , 1033 <code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"> 1034 <grant-uri-permission></a></code> 1035 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html"> 1036 <provider></a></code> . 1037 URI( ) . 1038 </p> 1039 <p> 1040 , 1041 {@link android.content.Intent#FLAG_GRANT_READ_URI_PERMISSION} 1042 {@link android.content.Intent#FLAG_GRANT_WRITE_URI_PERMISSION} , . 1043 {@link android.content.Intent#setFlags(int) setFlags()} . 1044 </p> 1045 <p> 1046 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#gprmsn"> 1047 android:grantUriPermissions</a></code> 1048 <code>false</code> . 1049 </p> 1050 </dd> 1051 </dl> 1052 1053 1054 1055 <!-- The Provider Element --> 1056 <h2 id="ProviderElement"><provider> </h2> 1057 <p> 1058 {@link android.app.Activity} {@link android.app.Service} , 1059 {@link android.content.ContentProvider} 1060 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html"> 1061 <provider></a></code> 1062 . Android 1063 . 1064 <dl> 1065 <dt> 1066 1067 (<a href="{@docRoot}guide/topics/manifest/provider-element.html#auth">{@code 1068 android:authorities}</a>) 1069 </dt> 1070 <dd> 1071 . 1072 1073 <a href="#ContentURI"> URI </a> . 1074 </dd> 1075 <dt> 1076 1077 (<code> 1078 <a href="{@docRoot}guide/topics/manifest/provider-element.html#nm">android:name</a> 1079 </code>) 1080 </dt> 1081 <dd> 1082 {@link android.content.ContentProvider} . 1083 1084 <a href="#ContentProvider">ContentProvider </a> . 1085 </dd> 1086 <dt> 1087 1088 </dt> 1089 <dd> 1090 1091 . 1092 <ul> 1093 <li> 1094 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#gprmsn"> 1095 android:grantUriPermssions</a></code>: . 1096 </li> 1097 <li> 1098 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#prmsn"> 1099 android:permission</a></code>: / . 1100 </li> 1101 <li> 1102 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#rprmsn"> 1103 android:readPermission</a></code>: . 1104 </li> 1105 <li> 1106 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#wprmsn"> 1107 android:writePermission</a></code>: . 1108 </li> 1109 </ul> 1110 <p> 1111 1112 1113 <a href="#Permissions"> </a> . 1114 </p> 1115 </dd> 1116 <dt> 1117 1118 </dt> 1119 <dd> 1120 Android , 1121 . 1122 <ul> 1123 <li> 1124 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#enabled"> 1125 android:enabled</a></code>: . 1126 </li> 1127 <li> 1128 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#exported"> 1129 android:exported</a></code>: . 1130 </li> 1131 <li> 1132 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#init"> 1133 android:initOrder</a></code>: 1134 . 1135 </li> 1136 <li> 1137 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#multi"> 1138 android:multiProcess</a></code>: 1139 . 1140 </li> 1141 <li> 1142 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#proc"> 1143 android:process</a></code>: 1144 . 1145 </li> 1146 <li> 1147 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#sync"> 1148 android:syncable</a></code>: 1149 . 1150 </li> 1151 </ul> 1152 <p> 1153 1154 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html"> 1155 <provider></a></code> 1156 . 1157 </p> 1158 </dd> 1159 <dt> 1160 1161 </dt> 1162 <dd> 1163 . 1164 <ul> 1165 <li> 1166 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#icon"> 1167 android:icon</a></code>: . 1168 1169 <em></em> > <em></em> > <em></em> . 1170 </li> 1171 <li> 1172 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#label"> 1173 android:label</a></code>: , . 1174 1175 <em></em> > <em></em> > <em></em> . 1176 </li> 1177 </ul> 1178 <p> 1179 1180 <code><a href="{@docRoot}guide/topics/manifest/provider-element.html"> 1181 <provider></a></code> . 1182 </p> 1183 </dd> 1184 </dl> 1185 1186 <!-- Intent Access --> 1187 <h2 id="Intents"> </h2> 1188 <p> 1189 {@link android.content.Intent} . 1190 {@link android.content.ContentResolver} 1191 {@link android.content.ContentProvider} . 1192 , . . 1193 UI . 1194 . 1195 UI "" . 1196 , 1197 . 1198 </p> 1199 <p> 1200 1201 </p> 1202 <p> 1203 . 1204 , . 1205 , 1206 . , . 1207 UI 1208 . 1209 </p> 1210 <p> 1211 . 1212 1213 <a href="{@docRoot}guide/components/intents-filters.html"> </a> . 1214 </p> 1215