You need to publish the content provider in your AndroidManifest.xml. There
is generally no reason to go through all of this trouble unless you want to
allow other applications to use your content provider, so you need to
describe in your manifest what it is so others can find it.
On Tue, Nov 25, 2008 at 9:05 PM, AndroidKid <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I've accessed existing Content Provider. ie, I've retrieved data from
> Contacts Application by including the Permission <Read_Contacts>
> within my application Android Manifest file.
>
> I've created new Content Provider by extending my class from Content
> Provider. I've overridded the method query(), delete(), update() &
> getType(). For that, I've included <provider> within AndroidManifest
> file.
>
> Now I would like to access my own content provider in another
> application. For this, I've tried the following code :
>
> package com.aspire.android.accessprovider;
>
> import android.app.Activity;
> import android.app.ListActivity;
> import android.content.ContentUris;
> import android.content.Intent;
> import android.database.Cursor;
> import android.net.Uri;
> import android.os.Bundle;
> import android.provider.Contacts.People;
> import android.view.View;
> import android.widget.ListAdapter;
> import android.widget.ListView;
> import android.widget.SimpleCursorAdapter;
> import com.aspire.android.wikinotes.database.WikiNote; // TO ACCESS MY
> OWN CONTENT PROVIDER
>
>
> public class OwnProviderAccessActivity extends ListActivity {
> private ListAdapter mAdapter;
>
> Uri uri = WikiNote.Notes.ALL_NOTES_URI;
> /** Called when the activity is first created. */
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> String auth = WikiNote.Notes.ALL_NOTES_URI.getAuthority();
> // Note the below line
> Cursor C = getContentResolver().query(WikiNote.Notes.ALL_NOTES_URI,
> null, null, null, null);
> startManagingCursor(C);
> // Here I've accessed one coulmn from the table in OwnContentProvider
> Applciation
> String[] columns = new String[] {WikiNote.Notes.TITLE};
> int[] names = new int[] {R.id.row_entry};
> mAdapter = new SimpleCursorAdapter(this, R.layout.contacts,
> C,
> columns, names);
> setListAdapter(mAdapter);
>
> }
>
> @Override
> protected void onListItemClick(ListView l, View v, int position,
> long
> id) {
> super.onListItemClick(l, v, position, id);
> }
> }
>
>
> I've got output by adding OWNCONTENTPROVIDER application within
> BuildPath.
>
> Here the source of entire OWNCONTENTPROVIDER application will be
> inclueded within the my OWNPROVIDERACCESS application. I would like
> to achieve the same thing using <permission> like Accessing Existing
> Content Provider.
>
> Please give your answers... I was totally confused .... I've stuck
> with this issue.
>
> Any kind of reply will be appreciated!!!
>
> Thanks in Advance!!!
> Yasmin
> >
>
--
Dianne Hackborn
Android framework engineer
[EMAIL PROTECTED]
Note: please don't send private questions to me, as I don't have time to
provide private support. All such questions should be posted on public
forums, where I and others can see and answer them.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---