I'm having problems with the content provider. I'm trying to create a content provider.
public static final Uri CONTENT_URI =
Uri.parse("content://data/data/one.two/databases");
This leads to my database as I want to extract data from it and show it in the list view. after which, I have to edit the manifest inserting the provider
<provider android:name="databases789"
android:grantUriPermissions="true"
android:enabled="true"
android:syncable="true"
android:authorities="one.two.databases" >
</provider>
- Have my URI been parsed correctly开发者_JAVA技巧?
- If I extend my class to Content Provider, my database file will be kinda screwed up, is there an easier way?
however, it shows the error of not having the one.two.databases to exist.
You may want to start here:
http://developer.android.com/guide/topics/providers/content-providers.html
A few specific tips to help:
First, your URI is not a path to the database file. It starts with "content://", then has an authority, then finally the database name (typically).
Your authority is a name you provide, usually your package name with 'provider' on the end. So yours might be one.two.provider.
Then you'd make a new class in your project, like MyProvider.java. Follow the example at the link up there for what to do in your provider to actually provide data.
Finally, in your AndroidManifest.xml file you'd do something like this:
<provider
android:authorities="one.two.provider"
android:name="MyProvider"
></provider>
This tells the android OS to hook your authority (one.two.provider) up to your class.
You must specify the name of your content provider in your AndroidManifest.xml
to your own ContentProvider
.
<provider android:name="com.app.MyContentProvider"
android:grantUriPermissions="true"
android:enabled="true"
android:syncable="true"
android:authorities="com.app.authorities.data" >
精彩评论