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

Android synching data between users

I have an android app that maintains a local SQLite database of different geographic locations. Now I would like to connect that database to the "cloud" to accomplish the following: an initial download of everything, when the app is first…
Brent
  • 16,259
  • 12
  • 42
  • 42
27
votes
2 answers

Why does ContentValues have a put method that supports Boolean?

The ContentValues class contains a method that allows Booleans to be put into the values collection. AFAIK, SQLite does not contain a native Boolean format that Android could push the boolean values into. So, what magic does Android do behind the…
Justin Breitfeller
  • 13,737
  • 4
  • 39
  • 47
27
votes
1 answer

How can I refresh the cursor from a CursorLoader?

So I have my MainDisplayActivity which implements both Activity and LoaderManager.LoaderCallbacks. Here I have A ListView, which I fill with Agenda information that I get from my database using a ContentProvider. I also have a GridView which…
25
votes
3 answers

How to transfer files between Android applications running on the same device?

I am writing an Android application that interfaces with a RESTful service. This web service essentially fronts a file system, and provides metadata as well CRUD access to the files. My application retrieves the metadata, and exposes it to 3rd…
Eric Levine
  • 13,536
  • 5
  • 49
  • 49
25
votes
2 answers

Android ContentProvider getType() called when and why

I put a log in getType() method it never gets printed. I am using the Notepad sample code. Please explain the 1st line of Java doc comment. Returning null from getType() is also working fine. What is the purpose of getType() method? /** * This…
Android Developer
  • 559
  • 1
  • 5
  • 17
25
votes
6 answers

Android/SQLite: Insert-Update table columns to keep the identifier

Currently, I am using the following statement to create a table in an SQLite database on an Android device. CREATE TABLE IF NOT EXISTS 'locations' ( '_id' INTEGER PRIMARY KEY AUTOINCREMENT, 'name' TEXT, 'latitude' REAL, 'longitude' REAL, …
JJD
  • 50,076
  • 60
  • 203
  • 339
24
votes
4 answers

Database handling with 2 processes

I have a an application that has 2 parts. A service which creates content. An application that uses the content Each of these run as different processes. The problem is that both of them share a database. And I frequently get database locked…
Codevalley
  • 4,593
  • 7
  • 42
  • 56
24
votes
4 answers

Cursor.getType() for API Level <11

I'm querying the CallLog content provider and need to detect the column types. In Honeycomb and newer (API Level 11+) you can get a columns preferred data type by calling the method Cursor.getType(int columnIndex) which returns one of the following…
jenzz
  • 7,239
  • 6
  • 49
  • 69
23
votes
2 answers

How do I catch content provider initialize?

As we know content provider loads on application run. But I want to make some operations before content provider will launch. How do I catch this operation? Before content provider's onCreate method would be called
pleerock
  • 18,322
  • 16
  • 103
  • 128
23
votes
6 answers

Using data from context providers or requesting Google Photos read permission?

My app allows users to import their photos and videos from other apps. Now that Google replaced Google+ Photos with Google Photos, couple of things broke for me. One of these things is re-using imported files after app restart. I have a feeling…
vkislicins
  • 3,331
  • 3
  • 32
  • 62
23
votes
2 answers

How to specify the sort order for the query to a content provider

I am trying to load all items from a Sqlite Table in Android and want to order the result. How do I specify the order for the returned cursor? I query the ContentProvider through a CursorLoader the following way: new CursorLoader(context,…
Janusz
  • 187,060
  • 113
  • 301
  • 369
23
votes
3 answers

Android SQLite database and app update

I have developed an android app and released version 1.0. The app contains SQLite local database with 5 tables. Now we planned to release version 2.0 also update the version 1.0 users. In version 2.0 we have included extra two tables with previous…
Rajesh Rajaram
  • 3,271
  • 4
  • 29
  • 48
22
votes
6 answers

How to Copy Image File from Gallery to another folder programmatically in Android

I want to pick image from gallery and copy it in to other folder in SDCard. Code to Pick Image from Gallery Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); …
22
votes
3 answers

get the last picture taken by user

hey I want to get the last picture captured by user through any camera application. I have no idea how to do that can any one help me? further I want to send that image as an attachment to an email or MMS.. thanks
ZeeShaN AbbAs
  • 1,365
  • 2
  • 15
  • 31
22
votes
2 answers

Which thread runs ContentProvider?

If I call to a ContentProvider from a Activity, which thread is ContentProvider running in? E.g. What happens if the Activity is killed and a query is executing in the ContentProvider? Say that you have a slow network query f.ex.
Torstein I. Bø
  • 1,359
  • 4
  • 14
  • 33