public class MyContentProvider extends ContentProvider {
private static final String AUTHORITY = "com.example.dh.myapplication.provider.MyContentProvider";
private static final String TABLE_INFORMATION = "informations";
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + File.separator + TABLE_INFORMATION);
public static final int INFORMATIONS = 1;
public static final int INFORMATIONS_ID = 2;
private MyDBHandler handler;
private static final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
static {
matcher.addURI(AUTHORITY, TABLE_INFORMATION, INFORMATIONS);
matcher.addURI(AUTHORITY, TABLE_INFORMATION + File.separator + "#", INFORMATIONS_ID);
}
public MyContentProvider() {
}
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
int uriType = matcher.match(uri);
SQLiteDatabase db = handler.getWritableDatabase();
int rowsDeleted = 0;
switch (uriType) {
case INFORMATIONS:
rowsDeleted = db.delete(TABLE_INFORMATION, selection, selectionArgs);
break;
case INFORMATIONS_ID:
String id = uri.getLastPathSegment();
if (TextUtils.isEmpty(selection)) {
rowsDeleted = db.delete(TABLE_INFORMATION, MyDBHandler.COLUMN_ID + "=" + id, null);
} else {
rowsDeleted = db.delete(TABLE_INFORMATION, MyDBHandler.COLUMN_ID + "=" + id + " and " + selection, selectionArgs);
}
break;
default:
throw new IllegalArgumentException("Unknown URI :" + uri);
}
getContext().getContentResolver().notifyChange(uri, null);
return rowsDeleted;
}
@Override
public String getType(Uri uri) {
// TODO: Implement this to handle requests for the MIME type of the data
// at the given URI.
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public Uri insert(Uri uri, ContentValues values) {
int uriType = matcher.match(uri);
SQLiteDatabase db = handler.getWritableDatabase();
long id = 0;
switch (uriType) {
case INFORMATIONS:
id = db.insert(TABLE_INFORMATION, null, values);
break;
default:
throw new IllegalArgumentException("Unknown URI :" + uri);
}
getContext().getContentResolver().notifyChange(uri, null);
return Uri.parse(TABLE_INFORMATION + File.separator + id);
}
@Override
public boolean onCreate() {
handler = new MyDBHandler(getContext(), null)
;
return false;
}
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
builder.setTables(TABLE_INFORMATION);
int uriType = matcher.match(uri);
switch (uriType) {
case INFORMATIONS:
break;
case INFORMATIONS_ID:
builder.appendWhere(MyDBHandler.COLUMN_ID + "=" + uri.getLastPathSegment());
break;
default:
throw new IllegalArgumentException("Unknown URI :" + uri);
}
Cursor cursor = builder.query(handler.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 = matcher.match(uri);
SQLiteDatabase db = handler.getWritableDatabase();
int rowsUpdated = 0;
switch (uriType) {
case INFORMATIONS:
rowsUpdated = db.update(TABLE_INFORMATION, values, selection, selectionArgs);
break;
case INFORMATIONS_ID:
String id = uri.getLastPathSegment();
if (TextUtils.isEmpty(selection)) {
rowsUpdated = db.update(TABLE_INFORMATION, values, MyDBHandler.COLUMN_ID + "=" + id, null);
} else {
rowsUpdated = db.update(TABLE_INFORMATION, values, MyDBHandler.COLUMN_ID + "=" + id + " and " + selection, selectionArgs);
}
break;
default:
throw new IllegalArgumentException("Unknown URI :" + uri);
}
getContext().getContentResolver().notifyChange(uri,null);
return rowsUpdated;
}
}
이게 CP의 코드이구요 매니페스트에 등록 했습니다.
public void add(View v) {
ContentValues values = new ContentValues();
String site = textSite.getText().toString();
String name = textName.getText().toString();
String password = textPassword.getText().toString();
values.put(COLUMN_SITE, site);
values.put(COLUMN_NAME, name);
values.put(COLUMN_PASSWORD, password);
Uri uri = resolver.insert(CONTENT_URI, values);
Toast.makeText(this, "추가됨. Uri : \n" + uri, Toast.LENGTH_SHORT).show();
}
이부분이 데이터를 엑세스하려는 또다른 앱의 함수인데 이 함수를 호출하면

이렇게 오류가 뜨네요 CP앱의 CONTENT_URI를 그대로 복사해서 작성해서 틀릴리가 없는데 왜이럴까요
고수님들 부탁드립니다!