android.provider是 Android SDK 中的一个包它提供了一系列用于访问系统级内容提供者Content Providers的类和常量。这些内容提供者封装了系统数据如联系人、短信、日历、媒体文件等并以标准化方式对外暴露数据接口供应用安全地读写。⚠️ 注意android.provider是Java API在 Kotlin 中可直接调用Kotlin 与 Java 完全互操作但没有专门的 Kotlin 原生替代包官方并未发布androidx.provider或kotlinx.provider等 Kotlin-first 封装。自 Android 10API 29起对ContactsContract、CallLog、MediaStore等 provider 的访问受到严格限制分区存储、运行时权限、作用域存储等需适配新行为。部分旧 API如android.provider.Telephony中的 SMS 相关类在 Android 8.0 已被标记为Deprecated推荐使用SmsManager或TelephonyManager替代。✅ 常见用法示例Kotlin// 查询联系人需 READ_CONTACTS 权限valuriContactsContract.Contacts.CONTENT_URIvalcursorcontentResolver.query(uri,arrayOf(ContactsContract.Contacts._ID,ContactsContract.Contacts.DISPLAY_NAME),null,null,null)cursor?.use{while(it.moveToNext()){validit.getString(it.getColumnIndexOrThrow(ContactsContract.Contacts._ID))valnameit.getString(it.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME))Log.d(Contact,$name(id:$id))}}✅ Java 等效写法仅语法差异UriuriContactsContract.Contacts.CONTENT_URI;CursorcursorgetContentResolver().query(uri,newString[]{ContactsContract.Contacts._ID,ContactsContract.Contacts.DISPLAY_NAME},null,null,null);if(cursor!null){while(cursor.moveToNext()){Stringidcursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts._ID));Stringnamecursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));Log.d(Contact,name (id: id));}cursor.close();} 关键点总结android.provider是平台级 Java 包Kotlin 通过 JVM 互操作无缝使用所有访问均需声明对应uses-permission并动态申请危险权限Android 6.0遵循作用域存储Scoped Storage规范Android 10避免直接路径访问推荐优先使用ContentResolverUri模式而非硬编码路径或反射。android.provider Kotlin |JavaProvides convenience classes to access the content providers supplied by Android.Android ships with a number of content providers that store common data such as contact informations, calendar information, and media files. These classes provide simplified methods of adding or retrieving data from these content providers.For information about how to use a content provider, see the Content Providers developer guide.InterfacesBaseColumnsCalendarContract.AttendeesColumns Columns from the Attendees table that other tables join into themselves.CalendarContract.CalendarAlertsColumnsCalendarContract.CalendarCacheColumnsCalendarContract.CalendarColumns Columns specific to the Calendars Uri that other Uris can query.CalendarContract.CalendarSyncColumns Generic columns for use by sync adapters.CalendarContract.ColorsColumnsCalendarContract.EventDaysColumnsCalendarContract.EventsColumns Columns from the Events table that other tables join into themselves.CalendarContract.ExtendedPropertiesColumnsCalendarContract.RemindersColumnsCalendarContract.SyncColumns Columns for Sync information used by Calendars and Events tables.Contacts.ContactMethodsColumns This interface was deprecated in API level 5. see ContactsContractContacts.ExtensionsColumns This interface was deprecated in API level 5. see ContactsContractContacts.GroupsColumns This interface was deprecated in API level 5. see ContactsContractContacts.OrganizationColumns This interface was deprecated in API level 5. see ContactsContractContacts.PeopleColumns This interface was deprecated in API level 5. see ContactsContractContacts.PhonesColumns This interface was deprecated in API level 5. see ContactsContractContacts.PhotosColumns This interface was deprecated in API level 5. see ContactsContractContacts.PresenceColumns This interface was deprecated in API level 5. see ContactsContractContacts.SettingsColumns This interface was deprecated in API level 5. see ContactsContractContactsContract.BaseSyncColumns Generic columns for use by sync adapters.ContactsContract.CommonDataKinds.BaseTypes The base types that all “Typed” data kinds support.ContactsContract.CommonDataKinds.CommonColumns Columns common across the specific types.ContactsContract.ContactNameColumns Contact name and contact name metadata columns in the RawContacts table.ContactsContract.ContactOptionsColumns Columns of ContactsContract.Contacts that track the user’s preferences for, or interactions with, the contact.ContactsContract.ContactsColumns Columns of ContactsContract.Contacts that refer to intrinsic properties of the contact, as opposed to the user-specified options found in ContactOptionsColumns.ContactsContract.ContactStatusColumnsContactsContract.DataColumns Columns in the Data table.ContactsContract.DataColumnsWithJoins Combines all columns returned by ContactsContract.Data table queries.ContactsContract.DataUsageStatColumns Columns in the Data_Usage_Stat tableContactsContract.DeletedContactsColumnsContactsContract.DisplayNameSources Types of data used to produce the display name for a contact.ContactsContract.FullNameStyle Constants for various styles of combining given name, family name etc into a full name.ContactsContract.GroupsColumnsContactsContract.PhoneLookupColumnsContactsContract.PhoneticNameStyle Constants for various styles of capturing the pronunciation of a person’s name.ContactsContract.PresenceColumns Additional data mixed in with StatusColumns to link back to specific ContactsContract.Data#_ID entries.ContactsContract.RawContactsColumnsContactsContract.SettingsColumnsContactsContract.StatusColumns Social status update columns.ContactsContract.SyncColumns Columns that appear when each row of a table belongs to a specific account, including sync information that an account may need.MediaStore.Audio.AlbumColumns Audio album metadata columns.MediaStore.Audio.ArtistColumns Audio artist metadata columns.MediaStore.Audio.AudioColumns Audio metadata columns.MediaStore.Audio.GenresColumns Audio genre metadata columns.MediaStore.Audio.PlaylistsColumns Audio playlist metadata columns.MediaStore.DownloadColumns Download metadata columns.MediaStore.Files.FileColumns File metadata columns.MediaStore.Images.ImageColumns Image metadata columns.MediaStore.MediaColumns Common media metadata columns.MediaStore.Video.VideoColumns Video metadata columns.OpenableColumns These are standard columns for openable URIs.SyncStateContract.ColumnsTelephony.BaseMmsColumns Base columns for tables that contain MMSs.Telephony.CanonicalAddressesColumns Columns for the “canonical_addresses” table used by MMS and SMS.Telephony.TextBasedSmsColumns Base columns for tables that contain text-based SMSs.Telephony.ThreadsColumns Columns for the “threads” table used by MMS and SMS.ClassesAlarmClock The AlarmClock provider contains an Intent action and extras that can be used to start an Activity to set a new alarm or timer in an alarm clock application.BlockedNumberContractThe contract between the blockednumber provider and applications.BlockedNumberContract.BlockedNumbers Constants to interact with the blocked numbers list.BrowserCalendarContractThe contract between the calendar provider and applications.CalendarContract.Attendees Fields and helpers for interacting with Attendees.CalendarContract.CalendarAlerts Fields and helpers for accessing calendar alerts information.CalendarContract.CalendarCache CalendarCache stores some settings for calendar including the current time zone for the instances.CalendarContract.CalendarEntity Class that represents a Calendar Entity.CalendarContract.Calendars Constants and helpers for the Calendars table, which contains details for individual calendars.CalendarContract.Colors Fields for accessing colors available for a given account.CalendarContract.EventDays Fields and helpers for querying for a list of days that contain events.CalendarContract.Events Constants and helpers for the Events table, which contains details for individual events.CalendarContract.EventsEntity Class that represents an Event Entity.CalendarContract.ExtendedProperties Fields for accessing the Extended Properties.CalendarContract.Instances Fields and helpers for interacting with Instances.CalendarContract.Reminders Fields and helpers for accessing reminders for an event.CalendarContract.SyncState A table provided for sync adapters to use for storing private sync state data.CallLog The CallLog provider contains information about placed and received calls.CallLog.Calls Contains the recent calls.Contacts This class was deprecated in API level 5. The APIs have been superseded by ContactsContract. The newer APIs allow access multiple accounts and support aggregation of similar contacts. These APIs continue to work but will only return data for the first Google account created, which matches the original behavior.Contacts.ContactMethods This class was deprecated in API level 5. see ContactsContractContacts.Extensions This class was deprecated in API level 5. see ContactsContractContacts.GroupMembership This class was deprecated in API level 5. see ContactsContractContacts.Groups This class was deprecated in API level 5. see ContactsContractContacts.Intents This class was deprecated in API level 5. see ContactsContractContacts.Intents.Insert This class was deprecated in API level 5. see ContactsContractContacts.Intents.UI This class was deprecated in API level 5. Do not use. This is not supported.Contacts.Organizations This class was deprecated in API level 5. see ContactsContractContacts.People This class was deprecated in API level 5. see ContactsContractContacts.People.ContactMethods This class was deprecated in API level 5. see ContactsContractContacts.People.Extensions This class was deprecated in API level 5. see ContactsContractContacts.People.Phones This class was deprecated in API level 5. see ContactsContractContacts.Phones This class was deprecated in API level 5. see ContactsContractContacts.Photos This class was deprecated in API level 5. see ContactsContractContacts.Settings This class was deprecated in API level 5. see ContactsContractContactsContractThe contract between the contacts provider and applications.ContactsContract.AggregationExceptionsConstants for the contact aggregation exceptions table, which contains aggregation rules overriding those used by automatic aggregation.ContactsContract.CommonDataKinds Container for definitions of common data types stored in the ContactsContract.Data table.ContactsContract.CommonDataKinds.CallableConvenient functionalities for “callable” data.ContactsContract.CommonDataKinds.Contactables A special class of data items, used to refer to types of data that can be used to attempt to start communicating with a person (Phone and Email).ContactsContract.CommonDataKinds.EmailA data kind representing an email address.ContactsContract.CommonDataKinds.EventA data kind representing an event.ContactsContract.CommonDataKinds.GroupMembershipGroup Membership.ContactsContract.CommonDataKinds.Identity A data kind representing an Identity related to the contact.ContactsContract.CommonDataKinds.ImA data kind representing an IM addressYou can use all columns defined for ContactsContract.Data as well as the following aliases.ContactsContract.CommonDataKinds.NicknameA data kind representing the contact’s nickname.ContactsContract.CommonDataKinds.NoteNotes about the contact.ContactsContract.CommonDataKinds.OrganizationA data kind representing an organization.ContactsContract.CommonDataKinds.PhoneA data kind representing a telephone number.ContactsContract.CommonDataKinds.PhotoA data kind representing a photo for the contact.ContactsContract.CommonDataKinds.RelationA data kind representing a relation.ContactsContract.CommonDataKinds.SipAddressA data kind representing a SIP address for the contact.ContactsContract.CommonDataKinds.StructuredName A data kind representing the contact’s proper name.ContactsContract.CommonDataKinds.StructuredPostalA data kind representing a postal addresses.ContactsContract.CommonDataKinds.WebsiteA data kind representing a website related to the contact.ContactsContract.Contacts Constants for the contacts table, which contains a record per aggregate of raw contacts representing the same person.ContactsContract.Contacts.AggregationSuggestionsA read-only sub-directory of a single contact aggregate that contains all aggregation suggestions (other contacts).ContactsContract.Contacts.AggregationSuggestions.Builder A convenience builder for aggregation suggestion content URIs.ContactsContract.Contacts.Data A sub-directory of a single contact that contains all of the constituent raw contact ContactsContract.Data rows.ContactsContract.Contacts.EntityA sub-directory of a contact that contains all of its ContactsContract.RawContacts as well as ContactsContract.Data rows.ContactsContract.Contacts.Photo A read-only sub-directory of a single contact that contains the contact’s primary photo.ContactsContract.DataConstants for the data table, which contains data points tied to a raw contact.ContactsContract.DataUsageFeedback This class was deprecated in API level 29. Contacts affinity information is no longer supported as of Android version Build.VERSION_CODES.Q. Both update and delete calls are always ignored.ContactsContract.DeletedContacts Constants for the deleted contact table.ContactsContract.Directory A Directory represents a contacts corpus, e.g. Local contacts, Google Apps Global Address List or Corporate Global Address List.ContactsContract.DisplayPhoto Helper class for accessing full-size photos by photo file ID.ContactsContract.Groups Constants for the groups table.ContactsContract.Intents Contains helper classes used to create or manage Intents that involve contacts.ContactsContract.Intents.Insert Convenience class that contains string constants used to create contact Intents.ContactsContract.PhoneLookup A table that represents the result of looking up a phone number, for example for caller ID.ContactsContract.PinnedPositionsContact-specific information about whether or not a contact has been pinned by the user at a particular position within the system contact application’s user interface.ContactsContract.Presence This class was deprecated in API level 5. This old name was never meant to be made public. Do not use.ContactsContract.ProfileConstants for the user’s profile data, which is represented as a single contact on the device that represents the user.ContactsContract.ProfileSyncState A table provided for sync adapters to use for storing private sync state data for the user’s personal profile.ContactsContract.ProviderStatus API for inquiring about the general status of the provider.ContactsContract.QuickContact Helper methods to display QuickContact dialogs that display all the information belonging to a specific Contacts entry.ContactsContract.RawContacts Constants for the raw contacts table, which contains one row of contact information for each person in each synced account.ContactsContract.RawContacts.Data A sub-directory of a single raw contact that contains all of its ContactsContract.Data rows.ContactsContract.RawContacts.DisplayPhotoA sub-directory of a single raw contact that represents its primary display photo.ContactsContract.RawContacts.EntityA sub-directory of a single raw contact that contains all of its ContactsContract.Data rows.ContactsContract.RawContactsEntityConstants for the raw contacts entities table, which can be thought of as an outer join of the raw_contacts table with the data table.ContactsContract.SearchSnippets Additional column returned by ContactsContract.Contacts#CONTENT_FILTER_URI explaining why the filter matched the contact.ContactsContract.SettingsContacts-specific settings for various Account’s.ContactsContract.StatusUpdatesA status update is linked to a ContactsContract.Data row and captures the user’s latest status update via the corresponding source, e.g.ContactsContract.SyncState A table provided for sync adapters to use for storing private sync state data for contacts.DocumentsContract Defines the contract between a documents provider and the platform.DocumentsContract.Document Constants related to a document, including Cursor column names and flags.DocumentsContract.Path Holds a path from a document to a particular document under it.DocumentsContract.Root Constants related to a root of documents, including Cursor column names and flags.DocumentsProvider Base class for a document provider.FontRequest Information about a font request that may be sent to a Font Provider.FontsContract Utility class to deal with Font ContentProviders.FontsContract.Columns Defines the constants used in a response from a Font Provider.FontsContract.FontFamilyResult Object returned from FontsContract.fetchFonts(Context, CancellationSignal, FontRequest).FontsContract.FontInfo Object represent a font entry in the family returned from FontsContract.fetchFonts(Context, CancellationSignal, FontRequest).FontsContract.FontRequestCallback Interface used to receive asynchronously fetched typefaces.LiveFolders This class was deprecated in API level 14. Live folders are no longer supported by Android. These have been replaced by the new AppWidget Collection APIs introduced in Build.VERSION_CODES.HONEYCOMB. These provide all of the features of live folders plus many more. The use of live folders is greatly discouraged because of security issues they introduce – publishing a live folder requires making all data show for the live folder available to all applications with no permissions protecting it.MediaStore The contract between the media provider and applications.MediaStore.Audio Collection of all media with MIME type of audio/.MediaStore.Audio.Albums Contains artists for audio filesMediaStore.Audio.Artists Contains artists for audio filesMediaStore.Audio.Artists.Albums Sub-directory of each artist containing all albums on which a song by the artist appears.MediaStore.Audio.Genres Contains all genres for audio filesMediaStore.Audio.Genres.Members Sub-directory of each genre containing all members.MediaStore.Audio.MediaMediaStore.Audio.Playlists Contains playlists for audio filesMediaStore.Audio.Playlists.Members Sub-directory of each playlist containing all members.MediaStore.Audio.RadioMediaStore.Downloads Collection of downloaded items.MediaStore.Files Media provider table containing an index of all files in the media storage, including non-media files.MediaStore.Images Collection of all media with MIME type of image/.MediaStore.Images.MediaMediaStore.Images.Thumbnails This class was deprecated in API level 29. Callers should migrate to using ContentResolver#loadThumbnail, since it offers richer control over requested thumbnail sizes and cancellation behavior.MediaStore.Video Collection of all media with MIME type of video/*.MediaStore.Video.MediaMediaStore.Video.Thumbnails This class was deprecated in API level 29. Callers should migrate to using ContentResolver#loadThumbnail, since it offers richer control over requested thumbnail sizes and cancellation behavior.SearchRecentSuggestions This is a utility class providing access to SearchRecentSuggestionsProvider.Settings The Settings provider contains global system-level device preferences.Settings.Global Global system settings, containing preferences that always apply identically to all defined users.Settings.NameValueTable Common base for tables of name/value settings.Settings.PanelA Settings panel is floating UI that contains a fixed subset of settings to address a particular user problem.Settings.Secure Secure system settings, containing system preferences that applications can read but are not allowed to write.Settings.System System settings, containing miscellaneous system preferences.SettingsSlicesContract Provides a contract for platform-supported Settings Slices.SyncStateContract The ContentProvider contract for associating data with ana data array account.SyncStateContract.ConstantsSyncStateContract.HelpersTelephony The Telephony provider contains data related to phone operation, specifically SMS and MMS messages, access to the APN list, including the MMSC to use, and the service state.Telephony.CarrierId Contains carrier identification information for the current subscriptions.Telephony.Carriers Carriers class contains information about APNs, including MMSC information.Telephony.Mms Contains all MMS messages.Telephony.Mms.Addr Contains address information for an MMS message.Telephony.Mms.Draft Contains all MMS messages in the MMS app drafts folder.Telephony.Mms.Inbox Contains all MMS messages in the MMS app inbox.Telephony.Mms.Intents Intents class.Telephony.Mms.Outbox Contains all MMS messages in the MMS app outbox.Telephony.Mms.Part Contains message parts.Telephony.Mms.Rate Message send rate table.Telephony.Mms.Sent Contains all MMS messages in the MMS app sent folder.Telephony.MmsSms Contains all MMS and SMS messages.Telephony.MmsSms.PendingMessages Contains pending messages info.Telephony.ServiceStateTable Constants for interfacing with the ServiceStateProvider and the different fields of the ServiceState class accessible through the provider.Telephony.Sms Contains all text-based SMS messages.Telephony.Sms.Conversations Contains a view of SMS conversations (also referred to as threads).Telephony.Sms.Draft Contains all draft text-based SMS messages in the SMS app.Telephony.Sms.Inbox Contains all text-based SMS messages in the SMS app inbox.Telephony.Sms.Intents Contains constants for SMS related Intents that are broadcast.Telephony.Sms.Outbox Contains all pending outgoing text-based SMS messages.Telephony.Sms.Sent Contains all sent text-based SMS messages in the SMS app.Telephony.Threads Helper functions for the “threads” table used by MMS and SMS.UserDictionary A provider of user defined words for input methods to use for predictive text input.UserDictionary.Words Contains the user defined words.VoicemailContract The contract between the voicemail provider and applications.VoicemailContract.Status Defines fields exposed through the /status path of this content provider.VoicemailContract.Voicemails Defines fields exposed through the /voicemail path of this content provider.ExceptionsSettings.SettingNotFoundException