contentresolver

Android: SQLite transactions when using ContentResolver

The goal: refresh database from XML data The process: Start transaction Delete all existing rows from the tables Per each main element of parsed XML insert row into main table and get PK Per each child of the main element insert record into 2nd table providing FK from the previous step Commit transaction Pretty standard stuff as far...

Android: Distinct and GroupBy in ContentResolver

What would be a sensible way to add DISTINCT and/or GROUPBY to ContentResolver- based queries. Right now I have to create custom URI for each special case. Is there a better way? (I still program for 1.5 as lowest common denominator) ...

How is advised to use the contentResolver's delete method to be injection safe?

You can delete with content resolver by URI or by passing some parameters to the where parameter. How do you make the parameters to be SQL Injection Safe? Is it possible to use Prepared Statements with ContentResolver? act.getContentResolver().delete(myuriwithid,null,null); act.getContentResolver().delete(mybaseuri," name = '"+this.nam...

Issue using Contact Group delete on Android

I have this code to delete a Contact Group public void delete(Activity act,String[] args) { try { int b=act.getContentResolver().delete(ContactsContract.Groups.CONTENT_URI,"_ID=?", args); Toast.makeText(act, "Deleted",Toast.LENGTH_SHORT).show(); //notify registered observers that a row was ...

Update doesn't work when using ContentResolver to update Contact Groups

I have this code for update: public Boolean update() { try { data.put(ContactsContract.Groups.SHOULD_SYNC, true); ContentResolver cr = ctx.getContentResolver(); Uri uri = ContentUris.withAppendedId(ContactsContract.Groups.CONTENT_URI, Long.parseLong(getId())); int mid = cr.update(uri, data,_ID+"="+getId(), null); // n...

How to get contacts in order of their upcoming birthdays?

I have code to read contact details and to read birthdays. But how do I get a list of contacts in order of their upcoming birthday? For a single contact identified by id, I get details and birthday like this: Cursor c = null; try { Uri uri = ContentUris.withAppendedId( ContactsContract.Contacts.CONTENT_URI, id); c = ctx.ge...

How to join a ContentResolver Cursor with a Database Cursor?

I get records from the system by quering a ContentResolver. I maintain the order of the items in the database. So I want to display the items in the order taken from my database. How do I merge these two informations? EDIT 1 I am looking after an alternative way now. As what I ideally want is: get order of contacts by a custom or...

Am I able to run SQL functions on a ContentResolver columns query?

I am wondering if Android's ContentResolver supports using SQL functions over the columns when you query a ContentProvider. Such as SQLite3 date functions, to get a specific date format, or datediff? What do you know about this? ...

Android: getting thumbnails from specific location on sd card

AFAIK accessing thumbnails for images via MediaStore.Images.Thumbnails would generate thumbnails at first attempt, and that's what i need to perform against specific location on sd card. The question is how to make valid URI to content under specific folder? All answers i can find use just MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_...

Android Create Playlist

Anyone know how to add playlists to Android in code? I kind of get that I have to insert it into the content resolver but do I have to just put the song id in or do I have to put all of the song's data in? I have been looking for sample code but haven't found any yet. EDIT: Found an answer here is how I do it: public static void ad...

Code to add contacts in android by using ContentResolver

How to add contacts in Android 2.2. Please help as I am not able to make it. I am adding contacts but it is not visible ...

Updating contact email address android

Hello, I'm trying to update email address of a contact from phonebook. But I'm not able to update and getting an empty values error on : updateValues.put(People.ContactMethods.KIND,android.provider.Contacts.KIND_EMAIL); updateValues.put(People.ContactMethods.DATA, newEmail); updateValues.put(People.ContactMethods.TYPE,ContactMethod...

How to store large blobs in an android content provider?

I have some large files (images and video) which I need to store in a content provider. The android documentation indicates... If you are exposing byte data that's too big to put in the table itself — such as a large bitmap file — the field that exposes the data to clients should actually contain a content: URI string. This...

Content Service Crash

I get weird exception: 10-31 09:09:51.308: ERROR/ContentService(59): Content Service Crash 10-31 09:09:51.308: ERROR/ContentService(59): java.lang.NullPointerException 10-31 09:09:51.308: ERROR/ContentService(59): at android.content.ContentService$ObserverNode.collectObserversLocked(ContentService.java:620) 10-31 09:09:51.308: ERROR...