ボタンをクリックしてコンテンツ プロバイダーにデータを追加するたびに、LogCat エラー「プロバイダー情報が見つかりませんでした」が発生し続けます
同じ問題に関する過去の投稿によると、プロバイダーがマニフェスト XML のアプリケーション部分の中にあることを確認し、当局が完全に書かれていることを確認しました。しかし、私はまだ同じエラーが発生しているようです。
マニフェスト XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ag.access"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="ag.access.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="ag.access.Farming"
android:label="@string/title_activity_farming"
android:parentActivityName="ag.access.MainActivity" >
<intent-filter>
<action android:name="ag.access.Farming" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ag.access.MainActivity" />
</activity>
<activity
android:name="ag.access.Dairy"
android:label="@string/title_activity_dairy"
android:parentActivityName="ag.access.MainActivity" >
<intent-filter>
<action android:name="ag.access.Dairy" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ag.access.MainActivity" />
</activity>
<activity
android:name="ag.access.Daily_log"
android:label="@string/title_activity_daily_log"
android:parentActivityName="ag.access.Dairy" >
<intent-filter>
<action android:name="ag.access.Daily_log" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ag.access.Dairy" />
</activity>
<activity
android:name="ag.access.Viewlogs"
android:label="@string/title_activity_viewlogs"
android:parentActivityName="ag.access.Daily_log" >
<intent-filter>
<action android:name="ag.access.Viewlogs" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ag.access.Daily_log" />
</activity>
<activity
android:name="ag.access.Add_Edit_Cows"
android:label="@string/title_activity_add__edit__cows"
android:parentActivityName="ag.access.Dairy" >
<intent-filter>
<action android:name="ag.access.Add_Edit_Cows" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ag.access.Dairy" />
</activity>
<activity
android:name="ag.access.Viewcows"
android:label="@string/title_activity_viewcows"
android:parentActivityName="ag.access.Add_Edit_Cows" >
<intent-filter>
<action android:name="ag.access.Viewcows" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ag.access.Add_Edit_Cows" />
</activity>
<provider
android:name="ag.access.cowsdb.provider.Cows_Provider"
android:authorities="ag.access.cowsdb.provider.Cows_Provider">
</provider>
</application>
</manifest>
コンテンツ プロバイダー Java:
package ag.access.cowsdb.provider;
import ag.access.cowsdb.Cowsdatabase;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.text.TextUtils;
public class Cows_Provider extends ContentProvider {
private Cowsdatabase cowsdbh;
private static final String Authority =
"ag.access.cowsdb.Cows_Provider";
private static final String Cows = "Cows";
public static final Uri Content_Uri = Uri.parse("content://" + Authority + "/" + Cows);
public static final int COWS = 1;
public static final int COWS_ID = 2;
private static final UriMatcher cURIMatcher =
new UriMatcher(UriMatcher.NO_MATCH);
static {
cURIMatcher.addURI(Authority, Cows, COWS);
cURIMatcher.addURI(Authority, Cows + "/#", COWS_ID);
}
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
int uriType = cURIMatcher.match(uri);
SQLiteDatabase mysqldb = cowsdbh.getWritableDatabase();
int rowsDeleted = 0;
switch (uriType) {
case COWS:
rowsDeleted = mysqldb.delete(Cowsdatabase.DATABASE_TABLE, selection, selectionArgs);
break;
case COWS_ID:
String id = uri.getLastPathSegment();
if (TextUtils.isEmpty(selection)) {
rowsDeleted = mysqldb.delete(Cowsdatabase.DATABASE_TABLE, Cowsdatabase.Key_Cow + "=" + id, null);
} else {
rowsDeleted = mysqldb.delete(Cowsdatabase.DATABASE_TABLE, Cowsdatabase.Key_Cow + "=" + id + " and " + selection, selectionArgs);
}
break;
default:
throw new IllegalArgumentException("Unknow URI: " + uri);
}
getContext().getContentResolver().notifyChange(uri, null);
return rowsDeleted;
}
@Override
public Uri insert(Uri uri, ContentValues values) {
int uriType = cURIMatcher.match(uri);
SQLiteDatabase mydb = cowsdbh.getWritableDatabase();
long id = 0;
switch (uriType) {
case COWS:
id = mydb.insert(Cowsdatabase.DATABASE_TABLE, null, values);
break;
default:
throw new IllegalArgumentException("Unknow Uri: " + uri);
}
getContext().getContentResolver().notifyChange(uri, null);
return Uri.parse(Cows + "/" + id);
}
@Override
public boolean onCreate() {
cowsdbh = new Cowsdatabase(getContext(), null, null, 1);
return false;
}
@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(cowsdbh.DATABASE_TABLE);
int uriType = cURIMatcher.match(uri);
switch (uriType) {
case COWS_ID:
qb.appendWhere(cowsdbh.Key_Cow + "=" + uri.getLastPathSegment());
break;
case COWS:
break;
default:
throw new IllegalArgumentException("Unknown URI");
}
Cursor cursor = qb.query(cowsdbh.getReadableDatabase(), projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
return cursor;
}
@Override
public int update(Uri uri, ContentValues values, String selection,
String[] selectionArgs) {
int uriType = cURIMatcher.match(uri);
SQLiteDatabase mysqldb = cowsdbh.getWritableDatabase();
int rowsUpdated = 0;
switch (uriType) {
case COWS:
rowsUpdated = mysqldb.update(Cowsdatabase.DATABASE_TABLE, values, selection, selectionArgs);
break;
case COWS_ID:
String id = uri.getLastPathSegment();
if (TextUtils.isEmpty(selection)) {
rowsUpdated =
mysqldb.update(Cowsdatabase.DATABASE_TABLE, values, Cowsdatabase.Key_Cow + "=" + id, null);
} else {
rowsUpdated =
mysqldb.update(Cowsdatabase.DATABASE_TABLE, values, Cowsdatabase.Key_Cow + "=" + id + " and " + selection, selectionArgs);
}
break;
default:
throw new IllegalArgumentException("Unknown URI:" + uri);
}
getContext().getContentResolver().notifyChange(uri, null);
return rowsUpdated;
}
@Override
public String getType(Uri uri) {
// TODO Auto-generated method stub
return null;
}
}
この問題の解決を手伝ってください。