hi bobs
i followed u r suggestion. Now i over come exception ie read
permission denied.
But while quering data i got null
Below is my code in reading data in application2
String columns[] = new String[] { "_id","roll","name"};
Uri myUri = Uri.parse("content://com.example.mytable/table1");
ContentProviderClient cpc =
getContentResolver().acquireContentProviderClient(myUri);
Cursor cur = cpc.query(myUri, columns, null, null,null);
if(cur==null){
Toast.makeText(this, "Query returned null",
Toast.LENGTH_LONG).show();
}
else {
if (cur.moveToFirst()) {
String id = null;
String roll=null;
String userName = null;
do {
id = cur.getString(cur.getColumnIndex("_id"));
roll=cur.getString(cur.getColumnIndex("roll"));
userName = cur.getString(cur.getColumnIndex("name"));
Toast.makeText(this, id + " " +roll+" "+ userName,
Toast.LENGTH_LONG).show();
} while (cur.moveToNext());
}
}
can u give me any suggestion
Regards,
saikiran
On Apr 14, 12:53 pm, Bob Kerns <[email protected]> wrote:
> I believe your problem is that you don't declare the permissions with
> the <permission/> tag in the Application1 manifest.
>
> To verify this, I created two apps, with your manifests. I changed the
> package name from 'com.android' to 'com.example', because you
> shouldn't be using com.android, but otherwise used your manifests. I
> wrote a minimal bit of code for each app. I was able to reproduce the
> SecurityException.
>
> Once I added the following:
>
> <permission android:name="com.example.mytable.Permission.READ"
> android:protectionLevel="normal" android:description="@string/hello"></
> permission>
> <permission android:name="com.example.mytable.Permission.WRITE"
> android:protectionLevel="normal" android:description="@string/hello"></
> permission>
>
> And *redeployed* Application 2, it no longer got the security
> exception. (It started getting other errors, since I didn't really
> implement the provider's cursor, but they're the expected sort of
> error).
>
> Note that it is essential to deploy Application 2 again AFTER fixing
> Application 1, because the decisions about application permissions are
> made at installation time.
>
> On Apr 13, 4:41 am, kiran <[email protected]> wrote:
>
> > Hi sreehari thanks for your reply.
> > But i didn't solved my problem.
> > I will give some more inputs to you
> > Application1 Manifest file looks like this
> > <?xml version="1.0" encoding="utf-8"?>
> > <manifest xmlns:android="http://schemas.android.com/apk/res/android"
> > package="com.android.mytable"
> > android:versionCode="1"
> > android:versionName="1.0">
> > <application android:icon="@drawable/icon" android:label="@string/
> > app_name">
> > <activity android:name=".MyTable"
> > android:label="@string/app_name">
> > <intent-filter>
> > <action android:name="android.intent.action.MAIN" />
> > <category
> > android:name="android.intent.category.LAUNCHER" />
> > </intent-filter>
> > </activity>
> > <provider
> > android:name=".MyContentProviders"
> > android:authorities="com.android.mytable" //Here i didn't
> > understand what is this authority time being iam giving package name
> > of the application one
> > android:writePermission="com.android.mytable.Permission.WRITE"
> > android:readPermission="com.android.mytable.Permission.READ"
> > android:exported="true"
> > android:multiprocess="true"
> > />
>
> > </application>
> > <uses-sdk android:minSdkVersion="5" />
> > Application2:
> > In this application iam reading the database
> > its manifest file is
> > <?xml version="1.0" encoding="utf-8"?>
> > <manifest xmlns:android="http://schemas.android.com/apk/res/android"
> > package="mydir.program"
> > android:versionCode="1"
> > android:versionName="1.0">
> > <application android:icon="@drawable/icon" android:label="@string/
> > app_name">
> > <activity android:name=".MyActivity"
> > android:label="@string/app_name">
> > <intent-filter>
> > <action android:name="android.intent.action.MAIN" />
> > <category
> > android:name="android.intent.category.LAUNCHER" />
> > </intent-filter>
> > </activity>
>
> > </application>
>
> > <uses-permission android:name="com.android.mytable.Permission.READ" />
> > <uses-permission android:name="com.android.mytable.Permission.WRITE" /
>
> > </manifest>
>
> > Where com.android.mytable is the package name of Application One and
> > MyContentProviders is Class name which extends ContentProvider in
> > application One
>
> > Still iam getting the same problem ie security exception permission
> > denied to read com.android.mytable.MyContentProviders
>
> > Please can you help me if possible
> > Regards,
> > Saikiran
>
> > On Apr 12, 10:48 am, SREEHARI <[email protected]>
> > wrote:
>
> > > Hi,
>
> > > In the manifest file of both applications you have to give
> > > permissions.
> > > In the manifest file of application with content provider you have to
> > > give the following permission........
>
> > > <provider android:name="................."
> > > android:authorities="............................."
> > > android:readPermission = "/*Package name of Content
> > > provider*/.Permission.READ"
> > > android:writePermission = "/*Package name of Content
> > > provider*/.Permission.WRITE"
> > > android:multiprocess = "true" android:exported="true"
> > > />
>
> > > In the manifest file of application you going to use this provider,
> > > you havr to give uses permission
>
> > > <uses-permission android:name="/*Package name of Content
> > > provider*/.Permission.READ" />
> > > <uses-permission android:name="/*package name of Content
> > > provider*/.Permission.WRITE" />
>
> > > You have to give the same permissions in both manifests........
>
> > > Regards,
> > > SREEHARI.
>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
To unsubscribe, reply using "remove me" as the subject.