4

Suppose that you have AbcContentProvider which allows you to query/update it with it's content:// url.

Is it possible to see the names/values those can be updated or queried?

(This would be similar to "select * from table_abc" in an sql query or like "Show tables" from a database table)

frankish
  • 6,738
  • 9
  • 49
  • 100

2 Answers2

5

This will help:

Uri u = // your CONTENT_URI
Cursor c = context.getContentResolver(uri, null, null, null, null, null);
Log.d(TAG, "listing column for uri=" + uri);
for (int i = 0; i<c.getColumnCount(); i++) {
    Log.d(TAG, "column " + i + "=" + c.getColumnName(i));
}

If the remote ContentProvider is not accepting a null projection:

  1. If this is about an android internal ContentProvider: Read the android source code: http://source.android.com/
  2. If this is about some other app: Decompile it and read the source code: Android - How to decode and decompile any APK file?
  3. You can brute force the list by querying with single element projection with a list of (random/generated) names
Community
  • 1
  • 1
flx
  • 14,146
  • 11
  • 55
  • 70
  • getContentresolver does not accept any parameters and when I modify this answer to call query function with null projection[] parameter, It throws null pointer exception. – frankish Sep 07 '13 at 13:06
  • Well, that's bad luck. Most ContentProvider do a `select *` when passing null as projection. – flx Sep 07 '13 at 13:07
  • just added some ideas to the answer. – flx Sep 07 '13 at 13:10
  • Thanks. This is related to a ContentProvider that is specific to Samsung Galaxy S3 android source (or any Samsung device). So I think I can't find the source for that.. – frankish Sep 07 '13 at 13:11
  • Grab the providing apk and decompile it. – flx Sep 07 '13 at 13:12
  • I don't have that api. You mean that I have to root the device and copy everything on the disk to my computer and try to decompile "Settings" application of my Samsung Galaxy S3? – frankish Sep 07 '13 at 13:24
  • Right, that's what I meant. – flx Sep 07 '13 at 13:26
  • added brute forcing as option in the answer. – flx Sep 07 '13 at 13:36
  • Even though this does not solve my problem, I am convinced that I cannot get the information I want without the methods like the ones you've shared: I mark this as the answer. – frankish Sep 07 '13 at 14:12
0

have you read Cursor docs? if not: getColumnCount() & getColumnName(idx)

pskink
  • 23,874
  • 6
  • 66
  • 77