IllegalArgumentException: Unknown URL content:// CONTENT

First, move <provider> to be a child of <application>, not <activity>. Second, change android:exported=”true” to android:exported=”false”, until such time as you secure your ContentProvider. As it stands, once you fix the <provider> element location as noted above, any app can read and write anything in your provider, which is unlikely to be what the user … Read more

How to get a contact’s facebook id or url from native contacts / content resolver?

Got the reply from on the Google Group (http://groups.google.com/group/android-developers/browse_thread/thread/95110dd7a1e1e0b4): Access to Facebook friends via the contacts provider is restricted to a handful of system apps by the provider itself. Other applications cannot read that data. Therefore now I fetch an cache all contact names/id mappings via FB Graph api (http://graph.facebook.com/me/friends) and use that for the … Read more

Possible to use multiple authorities with FileProvider?

My solution to this problem has actually been to avoid relying on a single FileProvider parsing multiple authorities. While this doesn’t directly address the question as stated, I’m posting it for posterity. I updated my library to leverage an empty subclass of FileProvider, so that the library’s updated manifest provider entry is now: <provider android:name=”.flow.email.screenshot.BugShakerFileProvider” … Read more

how to get contact photo URI

To get the conatct id using the phone number use the following code: import android.provider.ContactsContract.PhoneLookup; public String fetchContactIdFromPhoneNumber(String phoneNumber) { Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); Cursor cursor = this.getContentResolver().query(uri, new String[] { PhoneLookup.DISPLAY_NAME, PhoneLookup._ID }, null, null, null); String contactId = “”; if (cursor.moveToFirst()) { do { contactId = cursor.getString(cursor .getColumnIndex(PhoneLookup._ID)); } while (cursor.moveToNext()); } … Read more

How to check database on not rooted android device

The following solution works only for apps that are debuggable. It may not work well on all devices, since ​​run-as command doesn’t work on some devices, especially with Jelly Bean. ​Create a *.bat file and copy the following scripts ​​ adb shell run-as [package] chmod 777 /data/data/[package]/databases/ adb shell run-as [package] chmod 777 /data/data/[package]/databases/[db_file_name] adb … Read more

What are the semantics of withValueBackReference?

This question relates to batch operation on a content provider. The example is modified from this related question. When creating a batch of operations first create a list of operations to perform using: ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(); then apply them to the content provider using the applyBatch method. ContentProviderResult[] results = this.getContentResolver().applyBatch(FooBar.AUTHORITY, operations); That … Read more

How to retrieve RCS messages from Android Devices

This is worked only in the device where google messaging is enabled : RCS message basically is stored in Uri.parse(“content://mms”) content providers.You can alternatively useTelephony.Mms.CONTENT_URI. You can read the RCS related message by passing the URI Uri.parse(“content://mms”) in the contentResolver. Actually mms content type read the both mms and RCS message. Sample code is given … Read more

get the last picture taken by user

// Find the last picture String[] projection = new String[]{ MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATA, MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME, MediaStore.Images.ImageColumns.DATE_TAKEN, MediaStore.Images.ImageColumns.MIME_TYPE }; final Cursor cursor = getContext().getContentResolver() .query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, MediaStore.Images.ImageColumns.DATE_TAKEN + ” DESC”); // Put it in the image view if (cursor.moveToFirst()) { final ImageView imageView = (ImageView) findViewById(R.id.pictureView); String imageLocation = cursor.getString(1); File imageFile = new File(imageLocation); if … Read more