Android 声明内容提供程序
这是我第一次使用内容提供商,但我遵循了,但当我运行程序时,它告诉我Android 声明内容提供程序,android,android-contentprovider,Android,Android Contentprovider,这是我第一次使用内容提供商,但我遵循了,但当我运行程序时,它告诉我找不到提供商信息 这是我的舱单 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.tyczj.bowling" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="11" />
找不到提供商信息
这是我的舱单
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tyczj.bowling"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="11" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity android:name="Tabs">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="BowlersList"></activity>
</application>
<provider android:name="com.tyczj.bowling.BowlersDB"
android:authorities="com.tyczj.bowling.bowlersdb">
</provider>
</manifest>
}
不确定我做错了什么?提供者需要在应用程序标记中
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tyczj.bowling"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="11" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity android:name="Tabs">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="BowlersList"></activity>
<provider android:name="com.tyczj.bowling.BowlersDB"
android:authorities="com.tyczj.bowling.bowlersdb">
</provider>
</application>
</manifest>
出现此错误是因为您在应用程序标记之外定义了提供程序。 所以,请在应用程序中定义您的提供者
<application
........
<provider
android:name="com.tyczj.bowling.BowlersDB"
android:authorities="com.tyczj.bowling.bowlersdb">
</provider>
</application>
这是为什么在Eclipse中使用Android清单编辑器的一个很好的例子。它将这些项目/组件放在语法正确的位置,因此不必担心这个问题。
另一种查看方法:在开始时考虑使用清单编辑器(整个期间都是),以确认清单的正确性。 < P>不应该调用<代码> db = dBelpBel.GeWrutabLabaseDebug();ContentProvider onCreate中的代码>。这是因为
SQLiteOpenHelper
文档中给出了getReadableDatabase
和getwriteabledatabase
的原因:
与getWritableDatabase类似,此方法可能需要很长时间才能返回,
因此,您不应该从应用程序主线程调用它,包括
来自ContentProvider.onCreate()
相反,保留对SQLiteOpenHelper实例的引用,并在query/insert/delete/update方法中调用getWritableDatabase/getReadableDatabase,如果使用加载程序,这些方法将异步调用
很抱歉,这不是直接针对问题的,但我在代码示例中到处都看到了这一点。好的,不要出现“找不到提供程序”错误,但现在它告诉我
列“\u id”不存在
?如果将提供程序标记放在应用程序标记之外,它将在Kit Kat中失败,但在其他任何地方都有效……在KK中,应用程序标记内部崩溃。
<application
........
<provider
android:name="com.tyczj.bowling.BowlersDB"
android:authorities="com.tyczj.bowling.bowlersdb">
</provider>
</application>