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
12
votes
2 answers

android: Implement app search suggestion based on server response

I need to build a search functionality in my android app which relies on json response from the server. The users will enter the search query in a searchview located in the actionbar. Based on what the user types a query will be made to the server…
Vihaan Verma
  • 12,815
  • 19
  • 97
  • 126
12
votes
1 answer

Listen to android calendar changes. (Sync/Delete/Insert etc..)

I've understand I have to use Content Provider to get all changes, but I also realized starting API14 there is a ready Content Provider for the calendar which I can use to listen to instead of "building" my own custom one. Is there anywhere I can…
SagiLow
  • 5,721
  • 9
  • 60
  • 115
12
votes
1 answer

Android Calendar Provider: Is there a unique identifier for events, usable across multiple devices?

I'm using the Android Calendar Provider to display events. I'm also associating the events with images from a local app database by using the EVENT_ID of the event as a reference. I'm now wondering if it is possible to keep the same reference across…
12
votes
1 answer

How to load a Picasa image from URI?

I'm using ACTION_PICK intent to select an image from gallery. Some albums like "Posts", "Profile Photos", etc are marked with Picasa icon. For images from such albums I get a URI similar to…
12
votes
2 answers

What can cause StaleDataException other than prematurely calling cursor.close()?

I'm currently heavily modifying/rewriting an Android app and I have seen a very occasional crash along the following lines: a CursorAdapter method is called, it calls AbstractWindowedCursor#checkPosition(), and: 02-20 15:03:18.180…
12
votes
1 answer

What happen if return false in OnCreate of ContentProvider?

The document states that we should return true if the provider was successfully loaded, false otherwise. In my implementation, I would return false if DatabaseHelper == null. Suppose now DatabaseHelper == null and false is returned in onCreate, and…
Bear
  • 5,138
  • 5
  • 50
  • 80
12
votes
1 answer

Dealing with (cross-process) exceptions in Android custom content provider

I have a custom content provider in my Android app that works reasonably well. I expect other apps to also access my content provider. I would like some clean way to communicate exceptions and errors, but as far as I can tell the Android content…
12
votes
2 answers

How to properly insert values into the SQLite database using ContentProvider's insert() method through a CursorLoader?

I was reading the doc, but I am still not too sure. Its says to use getContentResolver(), but then that really isn't using CursorLoader. So is there a way to do it through CursorLoader? I know how to do it with query(). Are the steps very similar?…
11
votes
3 answers

Android ContentProvider calls bursts of setNotificationUri() to CursorAdapter when many rows are inserted with a batch operation

I have a custom ContentProvider which manages the access to a SQLite database. To load the content of a database table in a ListFragment, I use the LoaderManager with a CursorLoader and a CursorAdapter: public class MyListFragment extends…
11
votes
3 answers

CursorLoader for Multiple ContentProviders

I need to make a ListAdapter that presents data from multiple ContentProviders. The ContentProviders themselves represent one table each from relational database. I want to use the CursorLoader system to retrieve aggregate data into ListView. Is…
11
votes
2 answers

VIEW intent from a Content Provider URI?

I have some requirements to protect some sensitive data. The data is downloaded as a PDF from a URL and saved as an Application Private file using the following code: public File downloadPDF(final Context fileContext, Uri reportUri, final String…
Neal Sanche
  • 1,626
  • 16
  • 25
11
votes
2 answers

Android Contentprovider - update within an insert method

Is it ok to call the SQLiteDatabase update method in the insert() overridden method of a content provider?
Mak
  • 533
  • 7
  • 14
11
votes
1 answer

How to use ContentObserver with RecyclerView?

With ListView we have had a good native pattern to map some data from db to list: DB -> ContentProvider -> CursorLoader -> CursorAdapter -> ListView This approach was good in terms of data layer separation, performance and automatic data updates.…
11
votes
4 answers

Sharing and persisting data between multiple Android applications

I'm developing a group of complex Android applications that need to share common state and configuration settings. For example, see this picture explaining my scenario: I want that APP 1, APP 2 and APP 3 be able to access (read/write) data to the…
11
votes
3 answers

How to implement complex queries using a Content Provider?

I am asking this because I am not quite sure of how to work with Android Content Providers. I have a subset of my database with 8 tables and I need to create complex queries to get some of the data. My content provider works fine with simple…
Carla Urrea Stabile
  • 869
  • 1
  • 11
  • 35