My goal is to write ContentProvider without activity. For testing, I wrote test activity in my own application. For those who want to tell me that the recorder is still on in android, I know that.
Here is the part of ContentProvider
public static final String AUTHORITY = "de.xyz.android.log4android"; public static final int LOGGER_ARROW_URI_ID = 1; public static final String ARROW_CONTENT_TYPE = "vnd.de.xyz.android.cursor.dir/vnr.log"; public static final int LOGGER_ITEM_URI_ID = 2; public static final String ITEM_CONTENT_TYPE = "vnd.de.xyz.android.cursor.item/vnr.log"; public static final UriMatcher sUriMatcher; static { sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); sUriMatcher.addURI(AUTHORITY, LOGGER_TABLE, LOGGER_ARROW_URI_ID); sUriMatcher.addURI(AUTHORITY, LOGGER_TABLE + "#", LOGGER_ITEM_URI_ID); } public static final Uri CONTENT_URI = Uri.parse("content://" + LogServiceProvider.AUTHORITY + "/logs"); public static final DefaultLogEntry LOG_ENTRY = null;
So, I also add Content Provider Information to manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.xyz.android.logger" android:versionCode="1" android:versionName="1.0"> <provider android:name="de.xyz.android.logger.LogServiceProvider" android:authorities="de.xyz.android.log4android"/> <application android:icon="@drawable/icon" android:label="@string/app_name"> <uses-sdk android:minSdkVersion="4" /> </application>
Here is a part of my Client activity, which is in a separate application.
ContentResolver cr = getContentResolver(); Uri getItem = Uri.parse("content://de.xyz.android.log4android/logs"); ContentValues values = new ContentValues(); values.put("level","WARNING"); values.put("time","1986-11-16"); values.put("message","FistTest"); values.put("owner","jsb"); values.put("file","testLog.java"); values.put("line","27"); Uri newItem = cr.insert(getItem, values);
LogCat informs me that TestClient cannot find ContentProvider
05-27 12: 42: 52.099: ERROR / ActivityThread (548): Could not find provider information for de.xyz.android.log4android
Where is my mistake. In my opinion, I mentioned all this in: Content Providers | Android It would be nice if you could give me a hint. If you need more code snippets to understand, ask me.