本文整理汇总了Java中android.content.ContentValues.clear方法的典型用法代码示例。如果您正苦于以下问题:Java ContentValues.clear方法的具体用法?Java ContentValues.clear怎么用?Java ContentValues.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.ContentValues
的用法示例。
在下文中一共展示了ContentValues.clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: restoreDeletedServerConfiguration
import android.content.ContentValues; //导入方法依赖的package包/类
/**
* Restores deleted configuration. Returns the ID of the first one.
* @return the DI of the restored configuration.
*/
public long restoreDeletedServerConfiguration(final String name) {
mSingleArg[0] = name;
final ContentValues values = mValues;
values.clear();
values.put(ConfigurationContract.Configuration.DELETED, 0);
mDatabase.update(Tables.CONFIGURATIONS, values, NAME_SELECTION, mSingleArg);
final Cursor cursor = mDatabase.query(Tables.CONFIGURATIONS, ID_PROJECTION, NAME_SELECTION, mSingleArg, null, null, null);
try {
if (cursor.moveToNext())
return cursor.getLong(0 /* _ID */);
return -1;
} finally {
cursor.close();
}
}
示例2: init_apply_nextmulti_apply_pop_apply_shouldYieldFirstParentIdValues
import android.content.ContentValues; //导入方法依赖的package包/类
@Test
public void init_apply_nextmulti_apply_pop_apply_shouldYieldFirstParentIdValues() throws Exception {
MimeStructureState state = MimeStructureState.getNewRootState();
ContentValues cv = new ContentValues();
state.applyValues(cv);
state = state.nextMultipartChild(123);
cv.clear();
state.applyValues(cv);
state = state.nextMultipartChild(456);
state = state.popParent();
cv.clear();
state.applyValues(cv);
Assert.assertEquals(123L, cv.get("root"));
Assert.assertEquals(123L, cv.get("parent"));
Assert.assertEquals(2, cv.get("seq"));
Assert.assertEquals(3, cv.size());
}
示例3: insertLocation
import android.content.ContentValues; //导入方法依赖的package包/类
public void insertLocation(Location loc) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(Constants.DATABASE.LOCATION_NAME, loc.getLoactionName());
values.put(Constants.DATABASE.LOCATION_TYPE, loc.getLocationType());
values.put(Constants.DATABASE.LOCATION_STICKER_UUID, loc.getStickerUuid());
values.put(Constants.DATABASE.LOCATION_X, loc.getLocationX());
values.put(Constants.DATABASE.LOCATION_Y, loc.getLocationY());
values.put(Constants.DATABASE.LOCATION_COOR_X, loc.getCoordinateX());
values.put(Constants.DATABASE.LOCATION_COOR_Y, loc.getCoordinateY());
values.put(Constants.DATABASE.LOCATION_FLOOR_ID, loc.getFloorId());
db.insert(Constants.DATABASE.LOCATION_TABLE_NAME, null, values);
values.clear();
db.close();
}
示例4: createFtsSearchTable
import android.content.ContentValues; //导入方法依赖的package包/类
static void createFtsSearchTable(SQLiteDatabase db, MigrationsHelper migrationsHelper) {
MessageFulltextCreator fulltextCreator = MessageFulltextCreator.newInstance();
ContentValues cv = new ContentValues();
db.execSQL("CREATE VIRTUAL TABLE messages_fulltext USING fts4 (fulltext)");
try {
List<Long> folders = fetchFolders(db);
for (Long folderDatabaseId : folders) {
List<String> messageUids = fetchAllMessageUids(db, folderDatabaseId);
for (String messageUid : messageUids) {
LocalMessageData localMessageData = getMessage(db, messageUid, folderDatabaseId);
loadMessageParts(db, localMessageData, migrationsHelper.getAccount().getUuid(),
migrationsHelper.getLocalStore());
String fulltext = fulltextCreator.createFulltext(localMessageData);
if (!TextUtils.isEmpty(fulltext)) {
Timber.d("fulltext for msg id %d is %d chars long", localMessageData.getDatabaseId(),
fulltext.length());
cv.clear();
cv.put("docid", localMessageData.getDatabaseId());
cv.put("fulltext", fulltext);
db.insert("messages_fulltext", null, cv);
} else {
Timber.d("no fulltext for msg id %d :(", localMessageData.getDatabaseId());
}
}
}
} catch (MessagingException e) {
Timber.e(e, "error indexing fulltext - skipping rest, fts index is incomplete!");
}
}
示例5: createContentValuesFor
import android.content.ContentValues; //导入方法依赖的package包/类
/**
* Creates the content values to update Fuel Price(petrol and diesel both) in the database.
*
* @param fuelPrice the price of fuel
* @return ContentValues containing updatable data.
*/
private static ContentValues createContentValuesFor(String columnName, String fuelPrice) {
ContentValues values = new ContentValues();
values.clear();
values.put(columnName, fuelPrice);
return values;
}
示例6: addConfiguration
import android.content.ContentValues; //导入方法依赖的package包/类
/**
* Adds new configuration to the database.
* @param name the configuration name
* @param configuration the XML
* @return the id or -1 if error occurred
*/
public long addConfiguration(final String name, final String configuration) {
final ContentValues values = mValues;
values.clear();
values.put(ConfigurationContract.Configuration.NAME, name);
values.put(ConfigurationContract.Configuration.XML, configuration);
values.put(ConfigurationContract.Configuration.DELETED, 0);
return mDatabase.replace(Tables.CONFIGURATIONS, null, values);
}
示例7: startGuokrCache
import android.content.ContentValues; //导入方法依赖的package包/类
/**
* 网络请求果壳的消息内容主体并存储
* @param id 对应的id
*/
private void startGuokrCache(final int id) {
Cursor cursor = db.query("Guokr", null, null, null, null, null, null);
if (cursor.moveToFirst()) {
do {
if ((cursor.getInt(cursor.getColumnIndex("guokr_id")) == id)
&& (cursor.getString(cursor.getColumnIndex("guokr_content")).equals(""))) {
StringRequest request = new StringRequest(Api.GUOKR_ARTICLE_LINK_V1 + id, new Response.Listener<String>() {
@Override
public void onResponse(String s) {
ContentValues values = new ContentValues();
values.put("guokr_content", s);
db.update("Guokr", values, "guokr_id = ?", new String[] {String.valueOf(id)});
values.clear();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
}
});
request.setTag(TAG);
VolleySingleton.getVolleySingleton(CacheService.this).getRequestQueue().add(request);
}
} while (cursor.moveToNext());
}
cursor.close();
}
示例8: createContentValuesForBookmark
import android.content.ContentValues; //导入方法依赖的package包/类
private static ContentValues createContentValuesForBookmark(BlogModel blogModel, int position) {
ContentValues values = new ContentValues();
values.clear();
values.put(BookmarkTable.POSITION, position);
values.put(BookmarkTable.TITLE, blogModel.getTitle());
values.put(BookmarkTable.DESCRIPTION, blogModel.getDescription());
return values;
}
示例9: updateAssociatedTableWithFK
import android.content.ContentValues; //导入方法依赖的package包/类
/**
* Update the foreign keys in the associated model's table.
*
* @param baseObj
* Current model that is persisted.
*/
private void updateAssociatedTableWithFK(DataSupport baseObj) {
Map<String, Set<Long>> associatedModelMap = baseObj.getAssociatedModelsMapWithFK();
ContentValues values = new ContentValues();
for (String associatedTableName : associatedModelMap.keySet()) {
values.clear();
String fkName = getForeignKeyColumnName(baseObj.getTableName());
values.put(fkName, baseObj.getBaseObjId());
Set<Long> ids = associatedModelMap.get(associatedTableName);
if (ids != null && !ids.isEmpty()) {
mDatabase.update(associatedTableName, values, getWhereOfIdsWithOr(ids), null);
}
}
}
示例10: saveStackBlocking
import android.content.ContentValues; //导入方法依赖的package包/类
private void saveStackBlocking() {
final ContentResolver resolver = getContentResolver();
final ContentValues values = new ContentValues();
final byte[] rawStack = DurableUtils.writeToArrayOrNull(mState.stack);
// Remember location for next app launch
final String packageName = getCallingPackageMaybeExtra();
values.clear();
values.put(ResumeColumns.STACK, rawStack);
values.put(ResumeColumns.EXTERNAL, 0);
resolver.insert(RecentsProvider.buildResume(packageName), values);
}
示例11: testUpdateWithStaticUpdate
import android.content.ContentValues; //导入方法依赖的package包/类
public void testUpdateWithStaticUpdate() {
ContentValues values = new ContentValues();
values.put("TEACHERNAME", "Toy");
int rowsAffected = DataSupport.update(Teacher.class, values, teacher.getId());
assertEquals(1, rowsAffected);
assertEquals("Toy", getTeacher(teacher.getId()).getTeacherName());
values.clear();
values.put("aGe", 15);
rowsAffected = DataSupport.update(Student.class, values, student.getId());
assertEquals(1, rowsAffected);
assertEquals(15, getStudent(student.getId()).getAge());
}
示例12: fillStates
import android.content.ContentValues; //导入方法依赖的package包/类
private void fillStates(SQLiteDatabase db, ContentValues values, JSONObject state,
String stateCode) throws JSONException {
values.clear();
values.put(StateTable.COLUMN_NAME, state.getString(JsonAttributes.STATE_NAME));
values.put(StateTable.COLUMN_CODE, stateCode);
db.insert(StateTable.NAME, null, values);
}
示例13: testUpdateAllRowsWithStaticUpdate
import android.content.ContentValues; //导入方法依赖的package包/类
public void testUpdateAllRowsWithStaticUpdate() {
int allRows = getRowsCount(studentTable);
ContentValues values = new ContentValues();
values.put("name", "Zuckerburg");
int affectedRows = DataSupport.updateAll(Student.class, values);
assertEquals(allRows, affectedRows);
String table = DBUtility.getIntermediateTableName(studentTable, DBUtility.getTableNameByClassName(Teacher.class.getName()));
allRows = getRowsCount(table);
values.clear();
values.putNull(studentTable + "_id");
affectedRows = DataSupport.updateAll(table, values);
assertEquals(allRows, affectedRows);
}
示例14: insertPath
import android.content.ContentValues; //导入方法依赖的package包/类
public void insertPath(Path path) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(Constants.DATABASE.PATH_DISTANCE, path.getDistance());
values.put(Constants.DATABASE.PATH_FLOOR_ID, path.getFloorId());
values.put(Constants.DATABASE.PATH_START_X, path.getStartX());
values.put(Constants.DATABASE.PATH_END_X, path.getEndX());
values.put(Constants.DATABASE.PATH_START_Y, path.getStartY());
values.put(Constants.DATABASE.PATH_END_Y, path.getEndY());
values.put(Constants.DATABASE.PATH_DIRECTION, path.getDirection());
db.insert(Constants.DATABASE.PATH_TABLE_NAME, null, values);
values.clear();
db.close();
}
示例15: insertNameAndDescription
import android.content.ContentValues; //导入方法依赖的package包/类
private void insertNameAndDescription(SQLiteDatabase db,
String name, String address, String description) {
ContentValues values = new ContentValues();
values.clear();
values.put(RepoTable.Cols.NAME, name);
values.put(RepoTable.Cols.DESCRIPTION, description);
db.update(RepoTable.NAME, values, RepoTable.Cols.ADDRESS + " = ?", new String[]{
address,
});
}