这些子类在getDataRowHandler方法中中通过mimetype进行调用:
public DataRowHandler getDataRowHandler(final String mimeType) {
if (inProfileMode()) {
return getDataRowHandlerForProfile(mimeType);
}
DataRowHandler handler = mDataRowHandlers.get(mimeType);
if (handler == null) {
handler = new DataRowHandlerForCustomMimetype(
getContext(), mContactsHelper, mContactAggregator, mimeType);
mDataRowHandlers.put(mimeType, handler);
}
return handler;
}
getDataRowHandler方法在insertData,deleteData和updateData方法中被调用。
/**
* Inserts an item in the data table
*
* @param values the values for the new row
* @return the row ID of the newly created row
*/
private long insertData(ContentValues values, boolean callerIsSyncAdapter) {
long id = 0;
mValues.clear();
mValues.putAll(values);
long rawContactId = mValues.getAsLong(Data.RAW_CONTACT_ID);
// Replace package with internal mapping
final String packageName = mValues.getAsString(Data.RES_PACKAGE);
if (packageName != null) {
mValues.put(DataColumns.PACKAGE_ID, mDbHelper.get().getPackageId(packageName));
}
mValues.remove(Data.RES_PACKAGE);
// Replace mimetype with internal mapping
final String mimeType = mValues.getAsString(Data.MIMETYPE);
if (TextUtils.isEmpty(mimeType)) {
throw new IllegalArgumentException(Data.MIMETYPE + " is required");
}
mValues.put(DataColumns.MIMETYPE_ID, mDbHelper.get().getMimeTypeId(mimeType));
mValues.remove(Data.MIMETYPE);
DataRowHandler rowHandler = getDataRowHandler(mimeType);
id = rowHandler.insert(mActiveDb.get(), mTransactionContext.get(), rawContactId, mValues);
if (!callerIsSyncAdapter) {
mTransactionContext.get().markRawContactDirty(rawContactId);
}
mTransactionContext.get().rawContactUpdated(rawContactId);
return id;
}
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-36537-2.html
宝宝美哭