WEB开发网
开发学院手机开发Android 开发 Android 数据存储之 ContentProvider 阅读

Android 数据存储之 ContentProvider

 2010-03-03 16:44:00 来源:WEB开发网   
核心提示:null, sortOrder);default:throw new IllegalArgumentException("Uri IllegalArgument:" + uri);}}@Overridepublic int update(Uri uri, ContentValues values,

null, sortOrder);

default:

throw new IllegalArgumentException("Uri IllegalArgument:" + uri);

}

}

@Override

public int update(Uri uri, ContentValues values, String selection,

String[] selectionArgs) {

SQLiteDatabase db = this.openHelper.getWritableDatabase();

int result;

switch (uriMatcher.match(uri)) {

case CONTACT_LIST:

result = db.update(selection, values, selection, selectionArgs);

break;

case CONTACT:

long id = ContentUris.parseId(uri);

String where = "_id=" + id;

if (selection != null && !"".equals(selection)) {

where = where + " and " + selection;

}

result = db.update(tableName, values, where, selectionArgs);

break;

default:

throw new IllegalArgumentException("Uri IllegalArgument:" + uri);

}

return result;

}

}

2.添加ContentProvider配置

 <provider android:name=".provider.ContactContentProvider" android:authorities="com.changcheng.sqlite.provider.contactprovider"/>

android:authorities="com.changcheng.sqlite.provider.contactprovider" android:name=".provider.ContactContentProvider">

上一页  1 2 3 4 5 6  下一页

Tags:Android 数据 存储

编辑录入:coldstar [复制链接] [打 印]
赞助商链接