Hi,
Can any one tell me how to access the database in one application to other while using the content provider.
Table creation was successful and i am able to access the data in that application.
Here i am sending my code snippest for accessing the table in another application.
String columns[] = new String[] {"_id","roll","name"};
Uri myUri = Uri.parse("content://com.example.mytable/table1");
ContentProviderClient cpc = getContentResolver().acquireContentProviderClient(myUri);
Cursor cur=null;
try {
cur = cpc.query(myUri, null, null,null,null);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(cur==null){
Toast.makeText(this, "There is no records to Dispaly", Toast.LENGTH_LONG).show();
}
else{
if (cur.moveToFirst()) {
String id = null;
String roll=null;
String userName = null;
do {
id = cur.getString(cur.getColumnIndex(TABLE_ID));
userName = cur.getString(cur.getColumnIndex(TABLE_NAME));
roll=cur.getString(cur.getColumnIndex(TABLE_ROLL));
Toast.makeText(this, id + " " +roll+" "+ userName, Toast.LENGTH_LONG).show();
} while (cur.moveToNext());
i am getting the cur object as null. I gave the permissions to the table in the xml file
permission android:name="com.example.mytable.Permission.WRITE" androidrotectionLevel="normal" android:description="@string/hello" />
<permission android:name="com.example.mytable.Permission.READ" androidrotectionLevel="normal" android:description="@string/hello" />
so can please suggest me to over come this problem.
Can any one tell me how to access the database in one application to other while using the content provider.
Table creation was successful and i am able to access the data in that application.
Here i am sending my code snippest for accessing the table in another application.
String columns[] = new String[] {"_id","roll","name"};
Uri myUri = Uri.parse("content://com.example.mytable/table1");
ContentProviderClient cpc = getContentResolver().acquireContentProviderClient(myUri);
Cursor cur=null;
try {
cur = cpc.query(myUri, null, null,null,null);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(cur==null){
Toast.makeText(this, "There is no records to Dispaly", Toast.LENGTH_LONG).show();
}
else{
if (cur.moveToFirst()) {
String id = null;
String roll=null;
String userName = null;
do {
id = cur.getString(cur.getColumnIndex(TABLE_ID));
userName = cur.getString(cur.getColumnIndex(TABLE_NAME));
roll=cur.getString(cur.getColumnIndex(TABLE_ROLL));
Toast.makeText(this, id + " " +roll+" "+ userName, Toast.LENGTH_LONG).show();
} while (cur.moveToNext());
i am getting the cur object as null. I gave the permissions to the table in the xml file
permission android:name="com.example.mytable.Permission.WRITE" androidrotectionLevel="normal" android:description="@string/hello" />
<permission android:name="com.example.mytable.Permission.READ" androidrotectionLevel="normal" android:description="@string/hello" />
so can please suggest me to over come this problem.