I’m working on an Android app that needs to connect to various Content Providers, including Google Drive. But I’m having trouble finding the right provider for Drive.
I wrote some code to list all available providers on the device:
PackageManager pm = getPackageManager();
List<PackageInfo> packages = pm.getInstalledPackages(PackageManager.GET_PROVIDERS);
for (PackageInfo packageInfo : packages) {
ProviderInfo[] providerList = packageInfo.providers;
if (providerList != null) {
for (ProviderInfo info : providerList) {
Log.i("PROVIDER", "Authority: " + info.authority);
}
}
}
When I run this, I can see authorities like:
- com.google.android.apps.docs
- com.google.android.apps.docs.files
But nothing with ‘drive’ in the name shows up. Does this mean Google Drive doesn’t expose its content through a provider? I thought maybe different Google apps handle different file types from Drive, like Google Docs handling documents. But what about media files like videos and music stored in Drive? How can I access those programmatically?
yeah those authorities you found are the right ones but honestly content providers with drive are pretty hit or miss. ive tried this before and even with correct authority it only shows synced files. for media stuff like videos/music from drive you’re better off using the drive rest api directly - way more reliable than trying to hack around with content providers that google didnt really design for this use case.
I’ve dealt with this exact problem before and can confirm that Google Drive’s content provider implementation is quite limited. The com.google.android.apps.docs.files
authority you found is legitimate, but there’s a catch - it primarily exposes files through the Storage Access Framework (SAF) rather than traditional content provider queries.
What worked for me was using DocumentsContract API instead of trying to query the provider directly. You can access Drive files by launching an Intent with ACTION_OPEN_DOCUMENT or ACTION_GET_CONTENT, which will show the system file picker including Drive locations. This approach respects Google’s security model and works reliably across different Android versions.
For programmatic access without user interaction, the Drive API is definitely the way to go. The content provider route becomes especially problematic with media files since Drive doesn’t pre-sync everything locally. I learned this the hard way when my app would randomly fail to find files that users could clearly see in their Drive app.
The authorities you’re seeing are correct - Google Drive uses com.google.android.apps.docs.files
as its main content provider authority. However, accessing Drive files through content providers has significant limitations compared to using the official Drive API.
I ran into similar issues when trying to build a file manager app. The content provider approach only gives you access to files that are already cached locally on the device, and the permissions are quite restrictive. For media files like videos and music, you’ll often find that they’re not available through the provider unless they’ve been recently accessed and cached.
The proper way to access Drive files programmatically is through Google’s Drive API v3 with proper OAuth authentication. This gives you full access to the user’s Drive content, including metadata, sharing permissions, and the ability to download files on demand. The content provider is really meant for system-level file picker integration rather than direct app access.
If you absolutely need to stick with content providers, you’ll need to handle cases where files aren’t locally available and potentially prompt users to open files in the Drive app first to cache them.