因此,我创建了一个简单的内容提供者,但我发现了一个错误:
Failed to find provider info for com.b1.BooksContentProvider
I have 2 AVD names for 2.2 and 3.2 versions (I wrote random names for both of them)
3.2 because I use the v4 Fragment
support
So, I don t know if the problem comes from the manifest, or from the version I m using to launch the emulator.
我在此明确陈述:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.b1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".MyBooksActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/mt_books" />
<data android:mimeType="vnd.android.cursor.dir/mt_books" />
</intent-filter>
</activity>
<provider
android:authorities="com.b1.BooksContentProvider"
android:name="com.b1.BooksContentProvider"></provider>
</application>
</manifest>
以及我内容提供者的第一部分:
public class BooksContentProvider extends ContentProvider {
BooksDataBase mDB;
private static final String AUTHORITY = "com.b1.MyBooksActivity";
private static final String BASE_PATH = "books";
public static final Uri CONTENT_URI = Uri.parse("content:// " + AUTHORITY + "/" + BASE_PATH);
public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE
+ "/mt_books";
public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE
+ "/mt_books";
private static final UriMatcher sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH);
private static final int BOOK_DIR = 101;
private static final int BOOK_ITEM = 102;
static
{
sURIMatcher.addURI(AUTHORITY, BASE_PATH, BOOK_DIR);
sURIMatcher.addURI(AUTHORITY, BASE_PATH+"/#", BOOK_ITEM);
}
感谢您的帮助
附录
Ok, one of the possible mistake was :
i forgot to "import" the different classes
also, in the fragment XML : the LinearLayout did not work, i had to put a "TextView" alone in the XML