当前位置: 首页>>代码示例>>Java>>正文


Java ContentProvider类代码示例

本文整理汇总了Java中com.activeandroid.content.ContentProvider的典型用法代码示例。如果您正苦于以下问题:Java ContentProvider类的具体用法?Java ContentProvider怎么用?Java ContentProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ContentProvider类属于com.activeandroid.content包,在下文中一共展示了ContentProvider类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import com.activeandroid.content.ContentProvider; //导入依赖的package包/类
/**
 * Setups a number of mocks, parts of them static, to be able to push things
 * into ActiveAndroid internals, making simple tests possible.
 *
 * @throws Exception
 *					in case of an error - should not happen
 */
@Before
public void setup() throws Exception {
	PowerMockito.mockStatic(Cache.class);
	PowerMockito.mockStatic(ContentProvider.class);
	tableInfo = PowerMockito.mock(TableInfo.class);
	context = PowerMockito.mock(Context.class);
	ContentResolver resolver = PowerMockito.mock(ContentResolver.class);
	sqliteDb = PowerMockito.mock(SQLiteDatabase.class);
	ContentValues vals = PowerMockito.mock(ContentValues.class);
	PowerMockito.whenNew(ContentValues.class).withNoArguments().thenReturn(vals);
	PowerMockito.when(Cache.openDatabase()).thenReturn(sqliteDb);
	when(context.getContentResolver()).thenReturn(resolver);
	doNothing().when(resolver).notifyChange(any(Uri.class), any(ContentObserver.class));
	when(tableInfo.getFields()).thenReturn(new ArrayList<Field>());
	when(tableInfo.getTableName()).thenReturn(TABLE);
	PowerMockito.when(Cache.getTableInfo(any(Class.class))).thenReturn(tableInfo);
	PowerMockito.when(Cache.getContext()).thenReturn(context);
	PowerMockito.when(ContentProvider.createUri((Class<ValidatingModel>) anyObject(), anyLong())).thenReturn(null);
	onSetup();
}
 
开发者ID:vsigler,项目名称:ActiveAndroid-Validation,代码行数:28,代码来源:TestBase.java

示例2: execute

import com.activeandroid.content.ContentProvider; //导入依赖的package包/类
public <T extends Model> List<T> execute() {
	if (mQueryBase instanceof Select) {
		return SQLiteUtils.rawQuery(mType, toSql(), getArguments());
		
	} else {
		SQLiteUtils.execSql(toSql(), getArguments());
		Cache.getContext().getContentResolver().notifyChange(ContentProvider.createUri(mType, null), null);
		return null;
		
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:From.java

示例3: delete

import com.activeandroid.content.ContentProvider; //导入依赖的package包/类
public final void delete() {
	Cache.openDatabase().delete(mTableInfo.getTableName(), idName+"=?", new String[] { getId().toString() });
	Cache.removeEntity(this);

	Cache.getContext().getContentResolver()
			.notifyChange(ContentProvider.createUri(mTableInfo.getType(), mId), null);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Model.java

示例4: execute

import com.activeandroid.content.ContentProvider; //导入依赖的package包/类
public <T extends Model> List<T> execute() {
	if (mQueryBase instanceof Select) {
		return SQLiteUtils.rawQuery(mType, toSql(), getArguments());
	}
	else {
		SQLiteUtils.execSql(toSql(), getArguments());
		Cache.getContext().getContentResolver().notifyChange(ContentProvider
				.createUri(mType, null), null);
		return null;
	}
}
 
开发者ID:DobrinAlexandru,项目名称:Wabbit-Messenger---android-client,代码行数:12,代码来源:From.java

示例5: loadInBackground

import com.activeandroid.content.ContentProvider; //导入依赖的package包/类
@Override
public Cursor loadInBackground() {
    Uri uri = ContentProvider.createUri(QuestionHelper.getClass(contentSection), null);
    return getContext().getContentResolver().query(uri, null, null, null, "_id ASC");
}
 
开发者ID:tech-team,项目名称:decider-android,代码行数:6,代码来源:QuestionsLoader.java

示例6: loadInBackground

import com.activeandroid.content.ContentProvider; //导入依赖的package包/类
@Override
public Cursor loadInBackground() {
    Uri uri = ContentProvider.createUri(CategoryEntry.class, null);
    return getContext().getContentResolver().query(uri, null, null, null, null);
}
 
开发者ID:tech-team,项目名称:decider-android,代码行数:6,代码来源:CategoriesLoader.java

示例7: loadInBackground

import com.activeandroid.content.ContentProvider; //导入依赖的package包/类
@Override
public Cursor loadInBackground() {
    Uri uri = ContentProvider.createUri(CommentEntry.class, null);
    return getContext().getContentResolver().query(uri, null, "question_id = ?", new String[] { Integer.toString(questionId) }, "cid ASC");
}
 
开发者ID:tech-team,项目名称:decider-android,代码行数:6,代码来源:CommentsLoader.java

示例8: onCreateLoader

import com.activeandroid.content.ContentProvider; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String orderBy = ToasterModel.SHORT_JOB + " ASC, " + ToasterModel.NAME + " ASC";
    return new CursorLoader(this, ContentProvider.createUri(ToasterModel.class, null), null, null, null, orderBy);
}
 
开发者ID:twotoasters,项目名称:SectionCursorAdapter,代码行数:6,代码来源:MainActivity.java


注:本文中的com.activeandroid.content.ContentProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。