android-contentresolver

Android: Getting image bitmap from third party app (e.g. WhatsApp) via content:// URI

社会主义新天地 提交于 2019-11-28 01:14:57
问题 I am trying to get image from third party app (e.g WhatsApp) to my app (being tested on Marshmallow). When I do "share image" from WhatsApp and share it with my app, I get URI something like this: content://com.whatsapp.provider.media/item/61025 But in my app when I call getContentResolver().openInputStream(uri) or getContentResolver().openFileDescriptor(uri, "r") with above URI, it crashes with exception: java.lang.SecurityException: Permission Denial: opening provider com.whatsapp

How to properly insert values into the SQLite database using ContentProvider's insert() method through a CursorLoader?

不羁的心 提交于 2019-11-27 12:44:31
问题 I was reading the doc, but I am still not too sure. Its says to use getContentResolver() , but then that really isn't using CursorLoader. So is there a way to do it through CursorLoader ? I know how to do it with query() . Are the steps very similar? Even just a link that explains exactly this would be helpful. Please note, do not link me to the Google doc as they do not have an example that ever uses the insert() method from ContentProvider using a CursorLoader . Thanks in advance!! Edit: I

Can I perform this Android query with ContentResolver.query()? (LEFT JOIN and CASE)

∥☆過路亽.° 提交于 2019-11-27 12:25:54
I am looking to perform the following query (in pseudo-code) on Android: SELECT C.ID, C.NAME, CASE ISNULL(G.GROUPID,0) = 0 THEN 0 ELSE 1 END INGROUP FROM CONTACTS C LEFT JOIN GROUPMEMBERSHIP G ON G.CONTACTID = C.ID AND G.GROUPID = ? I am looking to select the ID and Name of ALL contacts in the system address book, via the default Contacts ContentProvider, along with a 0/1 field indicating whether the contact is a member of group ? . I could of course get all contacts easily enough, then loop through and query the membership separately easy enough in my Adapter class, but I'd imagine performing

How to get whatsapp Contacts from Android?

北城以北 提交于 2019-11-27 11:03:44
I have try to get whatsapp contact from phone and i get total Count of whatsapp contact but from RawContacts how to get whatsapp Number and name that i don't know. i have tried to find solution but can't get exact solution for that. Please help me. I put my code below. ContentResolver cr = context.getContentResolver(); Cursor c = cr.query( ContactsContract.RawContacts.CONTENT_URI, new String[] { ContactsContract.RawContacts.CONTACT_ID, ContactsContract.RawContacts.DISPLAY_NAME_PRIMARY }, ContactsContract.RawContacts.ACCOUNT_TYPE + "= ?", new String[] { "com.whatsapp" }, null); ArrayList<String

Android: SQLite transactions when using ContentResolver

*爱你&永不变心* 提交于 2019-11-27 09:21:59
问题 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 as db operations. The problem is that CRUD operations are not done within ContentProvider but rather using ContentResolver so the insert for example looks like

ContentProvider insert() always runs on UI thread?

落花浮王杯 提交于 2019-11-27 05:10:35
问题 I have an app that needs to pull data from a server and insert it into an SQLite database in response to user input. I thought this would be pretty simple - the code that pulls the data from the server is a fairly straightforward subclass of AsyncTask, and it works exactly as I expect it to without hanging the UI thread. I implemented callback functionality for it with a simple interface and wrapped it in a static class, so my code looks like this: MyServerCaller.getFolderContents(folderId,

How to store large blobs in an android content provider?

无人久伴 提交于 2019-11-27 04:00:58
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 is the field that gives clients access to the data file. The record should also have another field, named "_data" that lists the exact file path on the device for that file. This field is not intended to be read by the client, but by the ContentResolver. The client will

What is cursor.setNotificationUri() used for?

半世苍凉 提交于 2019-11-27 00:55:57
问题 I did research on how to use ContentProviders and Loaders from this tutorial How I see it: We have an Activity with ListView , SimpleCursorAdapter and CursorLoader . We also implement ContentProvider . In an Activity we can call getContentResolver().insert(URI, contentValues); via a button click. In our implementation of ContentProvider , at the end of insert() method, we call getContentResolver().notifyChange(URI, null); and our CursorLoader will receive message that it should reload data

what are uri, contentValues

感情迁移 提交于 2019-11-27 00:11:01
问题 Can anyone explain me about each term that I have used in working with calendar events? Uri event_uri = Uri.parse("content://com.android.calendar/" + "events"); What is uri here, what actually is content, as we can initialize int value to 0? Is it possible to initialize a uri with a default value? Uri reminder_uri = Uri.parse("content://com.android.calendar/" + "reminders"); What signifies these uri? What are the differences between event_uri and reminder_uri ? ContentValues values = new

Insertion of thousands of contact entries using applyBatch is slow

五迷三道 提交于 2019-11-27 00:09:42
I'm developing an application where I need to insert lots of Contact entries. At the current time approx 600 contacts with a total of 6000 phone numbers. The biggest contact has 1800 phone numbers. Status as of today is that I have created a custom Account to hold the Contacts, so the user can select to see the contact in the Contacts view. But the insertion of the contacts is painfully slow. I insert the contacts using ContentResolver.applyBatch. I've tried with different sizes of the ContentProviderOperation list(100, 200, 400), but the total running time is approx. the same. To insert all