KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to query custom content provider(App A) from another app(App B). I can do that when there is no permission protection for content provider. Specifically, I build custom content provider on App A and sent an intent containing the URI to App B. Here is intent-sending part in App A. class InsertOnClickListener implements OnClickListener{ public void onClick(View v) { ContentValues values = new ContentValues(); values.put(DataBaseConfiguation.TableConfiguation.USER_NAME, "Jack"); Uri uri = getContentResolver().insert(DataBaseConfiguation.TableConfiguation.CONTENT_URI, values); System.out.println("uri------------------->" + uri); // the uri above should be like "content://com.catking.contentprovider.MyContentProvider/user" Uri uri2 = Uri.parse("content://com.catking.contentprovider.MyContentProvider/user"); Cursor c = managedQuery(uri2, null, null, null, null); String sendvalue = null; if (c.moveToFirst()) { do{ System.out.println("User name:"+c.getString(c.getColumnIndex(DataBaseConfiguation.TableConfiguation.USER_NAME)).toString()); sendvalue = c.getString(c.getColumnIndex(DataBaseConfiguation.TableConfiguation.USER_NAME)).toString(); } while (c.moveToNext()); } Intent sendIntent = new Intent(); sendIntent.setClassName("com.android.web", "com.android.web.Provid"); sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); sendIntent.putExtra("name", uri2.toString()); sendIntent.setType("text/plain"); startActivity(sendIntent); } } followed by manifest file of App A. <application android:icon="@drawable/ic_launcher" android:label="@string/app_nam
Tags (comma-separated)
Save Edits
Cancel