English 中文(简体)
习俗内容提供者: em(未能找到提供者)的错误
原标题:Custom content provider: error from the emulator (failed to find provider info)
  • 时间:2012-01-12 21:37:58
  •  标签:
  • android

因此,我创建了一个简单的内容提供者,但我发现了一个错误:

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

最佳回答
private static final String AUTHORITY = "com.b1.MyBooksActivity";

这不是你在<条码>和>中所拥有的权力;provider>要素:

<provider
        android:authorities="com.b1.BooksContentProvider"
        android:name="com.b1.BooksContentProvider"></provider>

他们需要配对。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签