ContentProvider Permissions in AndroidManifest

Put your problem here if it does not fit any of the other categories.

ContentProvider Permissions in AndroidManifest

Postby frigo » Mon Jun 02, 2008 12:46 pm

Hi there,

For an application I wrote my own ContentProvider. Within this application it works fine, if i add the following to my manifest:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <manifest package="org.simple.test">
  3.  
  4. <application android:icon="@drawable/icon">
  5.  
  6.         <provider android:name="SimpleProvider" android:authorities="org.simple.provider.Provider"/>
  7.  
  8.         <activity>...</activity>
  9.  
  10. </application>
  11.  
  12. </manifest>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


now I want to access the Provider from another application - with this configuration I don't have access, so I have to add some permissions - does somebody know how to configure the manifest?

i can add android:readPermission="SOMETHING" and android:writePermission="SOMETHING" as attributes the the provider-tag to grant permissions - do I have to add them?

do I have to add the <permission> tag to grant access to my provider?

thanks, frigo
frigo
Freshman
Freshman
 
Posts: 5
Joined: Mon Jun 02, 2008 12:33 pm

Top

Postby frigo » Mon Jun 02, 2008 7:30 pm

Some strange discoveries:

here my manifest:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.    package="org.simple.test">
  7.  
  8.     <application android:icon="@drawable/icon">
  9.  
  10.         <provider android:name="SimpleProvider"
  11.  
  12.                android:authorities="org.simple.test.Provider"
  13.  
  14.                android:readPermission="org.simple.perm.READ_SIMPLY"
  15.  
  16.                android:writePermission="org.simple.perm.WRITE_SIMPLY"/>
  17.  
  18.         <activity android:name="SimpleProviderView" android:label="@string/app_name">
  19.  
  20. ...
  21.  
  22.         </activity>
  23.  
  24.     </application>
  25.  
  26.  
  27.  
  28.  
  29.  
  30. <permission android:label="@string/simple_read_label" android:protectionLevel="application" android:name="org.simple.perm.SIMPLE_READ"/>
  31.  
  32. <permission android:label="@string/simple_write_label" android:protectionLevel="application" android:name="org.simple.perm.SIMPLE_WRITE"/>
  33.  
  34. <uses-permission android:name="org.simple.perm.SIMPLE_READ"/>
  35.  
  36. <uses-permission android:name="org.simple.perm.SIMPLE_READ"/>
  37.  
  38. </manifest>
  39.  
  40.  
Parsed in 0.004 seconds, using GeSHi 1.0.8.4


if I define in the <provider> android:readPermission="..." I get a permission-error, even if I include <uses-permission>.
I tried with and without the additional <permission> tags with the same name, it doen't matter.

∼∼∼

However, here is a solution that works:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.    package="org.simple.test">
  7.  
  8.     <application android:icon="@drawable/icon">
  9.  
  10.         <provider android:name="SimpleProvider"
  11.  
  12.                android:authorities="org.simple.test.Provider"/>
  13.  
  14.         <activity android:name="SimpleProviderView" android:label="@string/app_name">
  15.  
  16. ...
  17.  
  18.         </activity>
  19.  
  20.     </application>
  21.  
  22.  
  23.  
  24.  
  25.  
  26. <permission android:label="@string/simple_read_label" android:protectionLevel="application" android:name="org.simple.perm.SIMPLE_READ"/>
  27.  
  28. <permission android:label="@string/simple_write_label" android:protectionLevel="application" android:name="org.simple.perm.SIMPLE_WRITE"/>
  29.  
  30. </manifest>
  31.  
  32.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


include in your other application <uses-permission android:name="org.simple.permission.XXX"/>

access the contentprovider in the application with:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.         Uri uri = Uri.parse("content://org.simple.test.Provider/simpleobject");
  3.  
  4.         Cursor c = this.getContentResolver().query(uri, null, null, null, null);
  5.  
  6.         // or whatever you'll need
  7.  
  8.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Does anybody know, how to solve the permission-problem when defining the readPermission/writePermission?
frigo
Freshman
Freshman
 
Posts: 5
Joined: Mon Jun 02, 2008 12:33 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 10 guests