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
13
votes
4 answers

What is the purpose of an Android projection map in a content provider?

I am looking at the Android notepad application sample code in /samples/android-16/NotePad/src/com/example/android/notepad. I was wondering if anyone could explain to me why the following code is needed in NotepadProvider.java? //…
Umbungu
  • 945
  • 3
  • 10
  • 30
13
votes
1 answer

What to set CursorAdapter(Context context, Cursor c, int flags) to in order to make it work with CursorLoader?

The google docs point out not to use the CursorAdapters first constructor, CursorAdapter(Context context, Cursor c) There are only two other options, CursorAdapter(Context context, Cursor c, boolean autoRequery) which says Constructor that…
13
votes
3 answers

Using Ormlite in Conjunction with Android's Content Provider

I'm in the process of developing an Android application and I am conflicted about whether or not I should use Ormlite for updating and retrieving data in conjunction with Android Content Provider. The content provider would be used to primarily…
dionysus
  • 439
  • 3
  • 12
  • 26
12
votes
3 answers

Querying Google Play Music database in Android

I am trying to query for the playlists created by "Google Play Music" app but haven't been able to do so. I created a playlist using locally stored content. I used the following code to query: Cursor c =…
Aman Bakshi
  • 231
  • 3
  • 6
12
votes
1 answer

Where is the SampleZipfileProvider class?

At the bottom of the section in Google's dev guide on expansion files (http://developer.android.com/guide/market/expansion-files.html#ZipLib) there is the following text. APEZProvider - Most applications don't need to use this class. This class…
elprl
  • 1,940
  • 25
  • 36
12
votes
2 answers

Android when to use ContentResolver applyBatch or BulkInsert

Right now for my application when I want to alter data for my ContentProvider, I just use the ContentResolver methods of insert, update, and delete. But on a couple of sample projects in the Android SDK, I notice they use applyBatch or BulkInsert.…
Hank
  • 3,367
  • 10
  • 48
  • 86
12
votes
4 answers

Declaring Content Provider

This is my first time using a content provider but I followed the developer docs but when I run the program it tells me failed to find provider info here is my manifest
tyczj
  • 71,600
  • 54
  • 194
  • 296
12
votes
2 answers

How to get bitmap providing a URI, java.io.FileNotFoundException: No content provider: /sdcard/Hello/1310610722879.jpg

I've read the example to do this: protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { Uri imageUri =…
Maurice
  • 6,413
  • 13
  • 51
  • 76
12
votes
3 answers

Android: Increment DB field via ContentValues

I'm updating an item in a ListView via the getContentResolver().update() method, and I'd like to increment a 'views' field via a ContentValue, but can't figure out if this is possible. I could do this with raw SQL SET views = views + 1, but setting…
Unpossible
  • 10,607
  • 22
  • 75
  • 113
12
votes
1 answer

Calling delete method in custom content provider

I am learning Android and I am stuck on an issue involving calling a custom content provider. I have been using an example in an instructional book and although it describes how to create the custom provider there is no clear example how to call the…
12
votes
3 answers

AccountManager does not add custom account in Android N preview

I have implemented a sync adapter in my app which requires an account to be added in the device account settings. I followed the same approach given in the Android docs. It works fine till Marshmallow and I can see my account listed in the device…
12
votes
1 answer

Android ContentProvider database query multiple tables

I'm writing an RSS reader for Android. I've faced a certain difficulty which the problem I can't resolve since databases aren't my expertise.. So i figured out maybe one of you could help me out! I currently have 3 tables (Categories, links and…
Antek Drzewiecki
  • 544
  • 1
  • 7
  • 18
12
votes
0 answers

Android Content Provider and Gradle productFlavours

I have app which should have 2 flavours: free and paid. Separately both versions works perfectly. But when I want to install 2 of them at once I'm getting error: [INSTALL_FAILED_CONFLICTING_PROVIDER]. I've tried to change android:authorities and…
12
votes
2 answers

Android - Querying the SMS ContentProvider?

I currently register a content observer on the following URI "content://sms/" to listen out for incoming and outgoing messages being sent. This seems to work ok and I have also tried deleting from the sms database but I can only delete an entire…
Donal Rafferty
  • 19,707
  • 39
  • 114
  • 191
12
votes
2 answers

is it possible to replace the MediaStore with a test double using robolectric?

I have a class that queries the MediaStore for images. For example, I have code that looks like someContentResolver.query( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, ... ). I want to test that, among other things, my queries to the MediaStore…