Questions tagged [android-contentprovider]

Content providers are one of the primary building blocks of Android applications, providing content to applications.

Content providers are one of the primary building blocks of Android applications, providing content to applications. They encapsulate data and provide it to applications through the single ContentResolver interface. A content provider is only required if you need to share data between multiple applications.

For example, the contacts data is used by multiple applications and must be stored in a content provider. If you don't need to share data amongst multiple applications you can use a database directly via SQLiteDatabase

For more information about using content providers, read the Content Provider's documentation.

3206 questions
15
votes
1 answer

Custom ContactsDirectoryProvider is not called for some operations

I've implemented custom ContactsDirectoryProvider which works fine when Contacts or Dialer applications are searching for contacts using URIs of the form content://com.android.contacts/data/phones/filter However when InCallUI or CallLog are trying…
15
votes
3 answers

Android: documentation for content://sms/ "type" values?

I know that the content://sms/ provider is not officially supported in Android. Nonetheless, I'm wondering if there are some commonly used conventions for the values that appear in the "type" column that can be returned from content://sms/…
NYCHippo
  • 377
  • 1
  • 4
  • 14
15
votes
3 answers

Get specific contact information from URI returned from Intent.ACTION_PICK

I am writing an Android app that has a data type that represents a person (specifically, the parent or guardian of a child). I'd like to be able to "import" the relevant data fields from the Contacts database in the Android device. (This should be…
15
votes
1 answer

Best practices for joining tables and notifying ContentObservers in Android ContentProvider

I have a ContentProvider which handles all the data insertion and retrieval related to my application, I'm following the pattern suggested by Virgil Dobjanschi on Google I/O. I am using the first pattern. My problem is that I have a logical entity…
CarlLee
  • 3,952
  • 5
  • 23
  • 33
14
votes
3 answers

How to add limit clause using content provider

Is there a way to limit the number of rows returned from content provider? I found this solution, however, it did not work for me. All of the rows are still being returned. Uri uri = Playlists.createIdUri(playlistId); //generates URI uri =…
heero
  • 1,941
  • 5
  • 23
  • 33
14
votes
1 answer

How to create a Thread-safe ContentProvider?

Android documentation says ContentProvider methods can be called from various ContentResolver objects in different processes and threads, they must be implemented in a thread-safe manner And I found this post on Stackoverflow Android - sqlite…
kakopappa
  • 5,023
  • 5
  • 54
  • 73
14
votes
1 answer

Search Suggestion results displayed as blank/no text

I have included a Search Dialog in my Activity which works fine. However adding Search Suggestions gives me a little problem: The search suggestion entries are "empty". I can see my content provider gets called (query(..)) and I return a…
MSurrow
  • 1,183
  • 2
  • 9
  • 23
14
votes
4 answers

Multiple rows insert with ContentProvider

I need to make insert of few rows in one transaction. Can I do it with ContentProvider?
earsonheart
  • 1,042
  • 2
  • 12
  • 25
14
votes
1 answer

Prevent network sync loop when syncing from network in Android ContentProvider

I'm writing my own ContentProvider which will be synced to a web service using a SyncAdapter. Problem happens when the sync adapter is modifying the content provider's data the provider triggers a network sync when internally calling…
m1h4
  • 1,139
  • 2
  • 13
  • 22
14
votes
4 answers

Permission Denial with File Provider through intent

I am attempting send a bitmap from the cache directory of my app to the text messaging app. I am using file provider to grant temporary permission to the application that handles the intent. When I try to send the intent and I select the default…
14
votes
1 answer

How to get a contact's facebook id or url from native contacts / content resolver?

How to get the facebook id or url of a contacts that's been synced to the native contacts app via Facebook sync adapter? I went through different urls, but didn't see any info regarding facebook. I…
Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192
14
votes
2 answers

How to run a singleton (shared) service in a library for multiple applications?

I've written a library starting a service in the background. It runs perfectly in all applications. In order to reduce the RAM usage, I want to avoid running multiple services for different applications. Actually, it's pretty enough to use only one…
14
votes
2 answers

Android: call custom methods in a ContentProvider

I have a custom ContentProvider I use to store fixes obtained from the GPS into a SQLite database. This class overrides ContentProvider methods (delete, insert, query...), but notice I have also included a method to query the last fix. public class…
Guido
  • 46,642
  • 28
  • 120
  • 174
14
votes
2 answers

How does Content Provider's application specify permissions that client apps need in order to access the provider's data?

BACKGROUND I am reading this tutorial on Android Content Providers. I understand from this tutorial that, In order for other applications to access a Content Provider's data, the provider application must specify the permissions which the client…
14
votes
6 answers

Failed to find provider info error

I am trying to have a contentprovider , but I am having trouble because I am getting an error of "Failed to find provider info for com.example.alex.hopefulyworks" Here is the manifest and the contentprovider