How to store large blobs in an android content provider?

The solution phreed gives in the bottom half of question is basically correct. I’ll try to add some more details here. When you do getContentResolver().openInputStream(…), content resolver will go to your content provider and call its openFile method. This is how the openFile looks in ContentProvider.java: public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException { … Read more

can we get chrome browsing history/bookmarks in our android app

Yes it is very much possible. Use this uri: content://com.android.chrome.browser/bookmarks instead of Browser.BOOKMARKS_URI String[] proj = new String[] { Browser.BookmarkColumns.TITLE,Browser.BookmarkColumns.URL }; Uri uriCustom = Uri.parse(“content://com.android.chrome.browser/bookmarks”); String sel = Browser.BookmarkColumns.BOOKMARK + ” = 0″; // 0 = history, 1 = bookmark Cursor mCur = getContentResolver().query(uriCustom, proj, sel, null, null); mCur.moveToFirst(); @SuppressWarnings(“unused”) String title = “”; @SuppressWarnings(“unused”) … Read more

Multiple Apps use same content provider

It’s an old question, but I was looking at doing something similar recently. With the Build flavours, its really straight forward now. Specify the BuildConfigField in the gradle file: productFlavors { free { applicationId “com.example.free” buildConfigField ‘String’, ‘AUTHORITY’, ‘”com.example.free.contentprovider”‘ } paid { applicationId “com.example.paid” buildConfigField ‘String’, ‘AUTHORITY’, ‘”com.example.paid.contentprovider”‘ } Specify the provider authority in the … Read more

How to use SMS content provider? Where are the docs?

In addition to those u can see the list of fields in sms content provider by using following code: private void displaySmsLog() { Uri allMessages = Uri.parse(“content://sms/”); //Cursor cursor = managedQuery(allMessages, null, null, null, null); Both are same Cursor cursor = this.getContentResolver().query(allMessages, null, null, null, null); while (cursor.moveToNext()) { for (int i = 0; i … Read more

How to restrict content provider data across applications

The easiest way is to protect the content provider with a permission you define. Make it a signature a permission so only apps signed with your certificate are allowed to get it. See: http://developer.android.com/guide/topics/security/security.html http://developer.android.com/reference/android/R.styleable.html#AndroidManifestProvider http://developer.android.com/guide/topics/manifest/provider-element.html If doing this based on certificates is not sufficient, you will need to write the permission checks yourself. This … Read more

CursorLoader not updating after data change

Did you call setNotificationUri(ContentResolver cr, Uri uri) on the Cursor before returning it in ContentProvider.query()? And did you call getContext().getContentResolver().notifyChange(uri, null) in the ‘insert’ method of your ContentProvider? EDIT: To get a ContentResolver call getContext().getContentResolver() in your ContentProvider.

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