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
10
votes
3 answers

Android: ContentProvider for each table / handling one-to-many relationships

When using a content provider for SQLite database access Is it better practice to have a content provider for each table or to use one for all tables? How to handle one-to-many relationships when creating new records?
jamesc
  • 12,423
  • 15
  • 74
  • 113
10
votes
1 answer

SecurityException: Permission Denial error

I've just upgraded to the new version of gmail (v2.3.5) and I've got an app that queries the content provider to get details about the contacts that messages are received for...... With the latest version I'm getting the below…
Andrew
  • 7,548
  • 7
  • 50
  • 72
10
votes
2 answers

how to store files in content providers

I have a requirement to attach a Zip file to a message in the Android email composer. The Zip file is being created by my application and stored in the app's private storage area (accessible via getFilesDirectory()). I am obtaining the URI to this…
brig
  • 305
  • 2
  • 6
  • 12
10
votes
0 answers

Unable to find resource ID - Android Gradle Plugin 3.4.0

When moving from Android Gradle Plugin 3.3.2 in a multi module project to 3.4.0 and executing connectedAndroidTest I see a fatal exception. A Google Play Services shared class StringResourceValueReader looks for a resource…
10
votes
3 answers

UnsupportedOperationException while calling getSharedPreferences() from unit test

I've implemented Content Provider that retrieves data from a service installed on network. The content provider takes required parameters from shared preferences (user credentials, app name, etc.) SharedPreferences settings =…
Glaxalg
  • 584
  • 6
  • 18
10
votes
1 answer

Using LiveData with Content Provider

I'm trying to use LiveData with the Content Provider on Android, however I cannot manage it because the Provider query method is as follows: public Cursor query so it returns a Cursor, while I need a LiveData. If I try to change the return type for…
ltedone
  • 639
  • 1
  • 6
  • 12
10
votes
1 answer

Android: Listening to contact changes like WhatsApp do

I'm building an App which relies heavily on the user's contacts. I've created an Account and create RawContacts on behalf of this account when needed. And I use SyncAdapter and things are great. But I'm still missing some parts of this…
10
votes
1 answer

Content Observer's onChange Method fired multiple Times

I know you are tempted to mark this a duplicate but wait, let's go through this again with my detailed (but failed) attempts. Strategy 1: Algorithm: Answer The first time the onChange is fired, get the id of the row updated The next time the…
10
votes
2 answers

What the appropriate replacer of deprecated " managedQuery"?

Android documentation said: This method was deprecated in API level 11. This is code: class GridViewActivity_ extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { …
ilw
  • 2,499
  • 5
  • 30
  • 54
10
votes
1 answer

Multiprocess Content Providers synced to default one

According to Android documentation : android:multiprocess Whether or not an instance of the content provider can be created in every client process — "true" if instances can run in multiple processes, and "false" if not. The default value is…
coolharsh55
  • 1,179
  • 4
  • 12
  • 27
10
votes
1 answer

SecurityException: Permission Denial: opening provider

I have the following problem. We have created a Game Center Application that provides a framework to create ad hoc wifi games and manages the highscores / encounters of such games. Database access for highscores is done with a provider:
10
votes
3 answers

Dynamically set the authority of a ContentProvider

Perhaps the title is a bit misleading. My problem is that I have an Android library project which is shared between two standard Android projects: one for a free version of the app and the other for a paid version. The library currently has the code…
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
10
votes
1 answer

How to create Cursor data without getting data from the DataBase in Android application?

In my Android application, I am using Sqlite DataBase to store the data from the server. I am using ContentProvider and ContentResolver to access the data from the DataBase and using CursorAdapter to bind the data to the ListView. As soon the data…
10
votes
0 answers

Adding custom mime type to contacts in android

I am trying to write an app that store data for the user for each contacts he chooses. I want to add to each user a custom provider (like facebook does) that on press will open my app and allow the user to review the stored data. I have created a…
10
votes
1 answer

Android, content provider in library project

I have a library project providing the base code for a number of apps that all needs the same database structure and functionality and I'm looking for the best way to implement this. My main concern is really about how to provide a non static…
jamesc
  • 12,423
  • 15
  • 74
  • 113