Insertion of thousands of contact entries using applyBatch is slow

Use ContentResolver.bulkInsert (Uri url, ContentValues[] values) instead of ApplyBatch() ApplyBatch (1) uses transactions and (2) it locks the ContentProvider once for the whole batch instead locking/unlocking once per operation. because of this, it is slightly faster than doing them one at a time (non-batched). However, since each Operation in the Batch can have a different … Read more

How to query Android MediaStore Content Provider, avoiding orphaned images?

Okay, I’ve found the problem with this code sample. In the onCreate() method, I had this line: mImageCursor = managedQuery( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, projection, selection, selectionArgs, null ); The problem here is that it’s querying for the thumbnails, rather than the actual images. The camera app on HTC devices does not create thumbnails by default, and so … Read more

tech