當前位置: 首頁>>代碼示例>>Java>>正文


Java ContentValues.clear方法代碼示例

本文整理匯總了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();
	}
}
 
開發者ID:runtimeco,項目名稱:Android-DFU-App,代碼行數:22,代碼來源:DatabaseHelper.java

示例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());
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:20,代碼來源:MigrationMimeStructureStateTest.java

示例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();
}
 
開發者ID:tringuyen1121,項目名稱:Khonsu,代碼行數:17,代碼來源:DatabaseOpenHelper.java

示例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!");
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:33,代碼來源:MigrationTo55.java

示例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;
}
 
開發者ID:andy1729,項目名稱:FuelFriend,代碼行數:13,代碼來源:DatabaseHelper.java

示例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);
}
 
開發者ID:runtimeco,項目名稱:Android-DFU-App,代碼行數:15,代碼來源:DatabaseHelper.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:32,代碼來源:CacheService.java

示例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;
}
 
開發者ID:mangoblogger,項目名稱:MangoBloggerAndroidApp,代碼行數:9,代碼來源:DatabaseHelper.java

示例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);
		}
	}
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:SaveHandler.java

示例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);
}
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:12,代碼來源:StandaloneActivity.java

示例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());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:UpdateUsingUpdateMethodTest.java

示例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);
}
 
開發者ID:andy1729,項目名稱:FuelFriend,代碼行數:8,代碼來源:DatabaseHelper.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:UpdateUsingUpdateMethodTest.java

示例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();
}
 
開發者ID:tringuyen1121,項目名稱:Khonsu,代碼行數:16,代碼來源:DatabaseOpenHelper.java

示例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,
    });
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:11,代碼來源:DBHelper.java


注:本文中的android.content.ContentValues.clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。