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


Java ContentValues.put方法代码示例

本文整理汇总了Java中android.content.ContentValues.put方法的典型用法代码示例。如果您正苦于以下问题:Java ContentValues.put方法的具体用法?Java ContentValues.put怎么用?Java ContentValues.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.ContentValues的用法示例。


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

示例1: updateNote

import android.content.ContentValues; //导入方法依赖的package包/类
/**
 * Actualiza los contenidos de una nota
 * @param note datos de la nota a actualizar
 * @return 1 si se ha actualizado la nota, 0 si no se ha localizado el id de la nota a actualizar en base de datos
 */
public int updateNote (Note note) {
    int rowsUpdated = 0;

    try {
        SQLiteDatabase db = this.getWritableDatabase();

        ContentValues values = new ContentValues();

        values.put(NoteTable.COLUMN_CONTENT, note.getContent());
        values.put(NoteTable.COLUMN_TITLE, note.getTitle());
        values.put(NoteTable.COLUMN_UPDATE_DATE, System.currentTimeMillis());

        String where = NoteTable._ID + " = ? ";
        String [] whereArgs = new String []{Long.toString(note.getId())};

        rowsUpdated = db.update(NoteTable.TABLE_NAME, values, where, whereArgs);

        db.close();

    } catch (Exception ex) {
        Log.e(AppConstants.APP_TAG, "Error en updateNote", ex);
    }

    return rowsUpdated;
}
 
开发者ID:gothalo,项目名称:Android-2017,代码行数:31,代码来源:DataBaseHelper.java

示例2: onItemClick

import android.content.ContentValues; //导入方法依赖的package包/类
@Override
public void onItemClick(Closeable closeable, int adapterPosition, int menuPosition, int direction) {
    closeable.smoothCloseMenu();// 关闭被点击的菜单。
    Post noteOne = noteList.get(adapterPosition);
    if (menuPosition == 0) {// 删除按钮被点击。
        mDatabase.delete(NoteDB.RECYCLE_TABLE, "id=?", new String[]{noteOne.getId() + ""});
        noteList.remove(adapterPosition);
        noteAdapter.notifyItemRemoved(adapterPosition);
        Toast.makeText(getApplicationContext(), "删除成功", Toast.LENGTH_SHORT).show();
    }
    if (menuPosition == 1) {//恢复按钮
        ContentValues cv = new ContentValues();
        cv.put(NoteDB.ID, noteOne.getId());
        cv.put(NoteDB.TITLE, noteOne.getTitle());
        cv.put(NoteDB.CONTENT, noteOne.getContent());
        cv.put(NoteDB.TIME, noteOne.getTime());
        mDatabase.insert(NoteDB.TABLE_NAME, null, cv);
        mDatabase.delete(NoteDB.RECYCLE_TABLE, "id=?", new String[]{noteOne.getId() + ""});
        noteList.remove(adapterPosition);
        noteAdapter.notifyItemRemoved(adapterPosition);
    }
}
 
开发者ID:weimin96,项目名称:shareNote,代码行数:23,代码来源:RecycleActivity.java

示例3: addSongData

import android.content.ContentValues; //导入方法依赖的package包/类
public void addSongData(SongData songData) {

        // Get table data
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues values = new ContentValues();

        // Get byte array from image
        Drawable cover = songData.getSongCover();
        Bitmap bitmap = ((BitmapDrawable) cover).getBitmap();
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
        byte[] img = stream.toByteArray();

        // Insert new data from song data
        values.put(KEY_NAME, songData.getSongName());
        values.put(KEY_PATH, songData.getSongPath());
        values.put(KEY_ARTIST, songData.getSongArtist());
        values.put(KEY_ALBUM, songData.getSongAlbum());
        values.put(KEY_GENRE, songData.getSongGenre());
        values.put(KEY_COVER, img);
        db.insert(TABLE_SONGS, null, values);
        db.close();
    }
 
开发者ID:Davarco,项目名称:Divertio,代码行数:24,代码来源:SongDBHandler.java

示例4: insert

import android.content.ContentValues; //导入方法依赖的package包/类
/**
 * Insert a checkpoint in the checkpoints table.
 *
 * @param checkpoint the checkpoint to insert
 * @return the id of the inserted row
 */
private long insert(CheckPoint checkpoint) {
    ContentValues valuesToInsert = new ContentValues();
    valuesToInsert.put(CHECKPOINTS_COLS[1], checkpoint.getLatitude());
    valuesToInsert.put(CHECKPOINTS_COLS[2], checkpoint.getLongitude());

    return db.insert(CHECKPOINTS_TABLE_NAME, null, valuesToInsert);
}
 
开发者ID:IrrilevantHappyLlamas,项目名称:Runnest,代码行数:14,代码来源:DBHelper.java

示例5: add

import android.content.ContentValues; //导入方法依赖的package包/类
public void add(Face face){
    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    //将数据按照键值对存入ContentValues
    ContentValues values = new ContentValues();
    values.put(FaceMetaData.FaceTable.IMAGE_ID, face.getImage_id());
    values.put(FaceMetaData.FaceTable.REQUEST_ID, face.getRequest_id());
    values.put(FaceMetaData.FaceTable.GENDER, face.getGender());
    values.put(FaceMetaData.FaceTable.GLASS, face.getGlass());
    values.put(FaceMetaData.FaceTable.ETHNICITY, face.getEthnicity());
    values.put(FaceMetaData.FaceTable.TIME_USED, face.getTime_used());
    values.put(FaceMetaData.FaceTable.AGE, face.getAge());
    values.put(FaceMetaData.FaceTable.FACE_RECTANGLE_WIDTH, face.getFace_rectangle_width());
    values.put(FaceMetaData.FaceTable.FACE_RECTANGLE_TOP, face.getFace_rectangle_top());
    values.put(FaceMetaData.FaceTable.FACE_RECTANGLE_LEFT, face.getFace_rectangle_left());
    values.put(FaceMetaData.FaceTable.FACE_RECTANGLE_HEIGHT, face.getFace_rectangle_height());
    values.put(FaceMetaData.FaceTable.LEFT_NORMAL_GLASS_EYE_OPEN, face.getLeft_normal_glass_eye_open());
    values.put(FaceMetaData.FaceTable.LEFT_NO_GLASS_EYE_CLOSE, face.getLeft_no_glass_eye_close());
    values.put(FaceMetaData.FaceTable.LEFT_OCCLUSION, face.getLeft_occlusion());
    values.put(FaceMetaData.FaceTable.LEFT_NO_GLASS_EYE_OPEN, face.getLeft_no_glass_eye_open());
    values.put(FaceMetaData.FaceTable.LEFT_NORMAL_GLASS_EYE_CLOSE, face.getLeft_normal_glass_eye_close());
    values.put(FaceMetaData.FaceTable.LEFT_DARK_GLASSES, face.getLeft_dark_glasses());
    values.put(FaceMetaData.FaceTable.RIGHT_NORMAL_GLASS_EYE_OPEN, face.getRight_normal_glass_eye_open());
    values.put(FaceMetaData.FaceTable.RIGHT_NO_GLASS_EYE_CLOSE, face.getRight_no_glass_eye_close());
    values.put(FaceMetaData.FaceTable.RIGHT_OCCLUSION, face.getRight_occlusion());
    values.put(FaceMetaData.FaceTable.RIGHT_NO_GLASS_EYE_OPEN, face.getRight_no_glass_eye_open());
    values.put(FaceMetaData.FaceTable.RIGHT_NORMAL_GLASS_EYE_CLOSE, face.getRight_normal_glass_eye_close());
    values.put(FaceMetaData.FaceTable.RIGHT_DARK_GLASSES, face.getRight_dark_glasses());
    values.put(FaceMetaData.FaceTable.HEADPOSE_YAW_ANGLE, face.getHeadpose_yaw_angle());
    values.put(FaceMetaData.FaceTable.HEADPOSE_PITCH_ANGLE, face.getHeadpose_pitch_angle());
    values.put(FaceMetaData.FaceTable.HEADPOSE_ROLL_ANGLE, face.getHeadpose_roll_angle());
    values.put(FaceMetaData.FaceTable.BLURNESS, face.getBlurness());
    values.put(FaceMetaData.FaceTable.SMILE, face.getSmile());
    values.put(FaceMetaData.FaceTable.FACEQUALITY,face.getFacequality());
    values.put(FaceMetaData.FaceTable.FACE_TOKEN,face.getFace_token());
    values.put(FaceMetaData.FaceTable.IMAGE_PATH,face.getImage_path());
    //执行插入操作
    db.insert(FaceMetaData.FaceTable.TABLE_NAME, FaceMetaData.FaceTable.IMAGE_ID,values);
    db.close();
    System.out.println("插入数据成功!");
}
 
开发者ID:HuaDanJson,项目名称:FaceAI_Android,代码行数:41,代码来源:DatebaseAdapter.java

示例6: updateWallpaper

import android.content.ContentValues; //导入方法依赖的package包/类
public void updateWallpaper(Wallpaper wallpaper) {
    if (!openDatabase()) {
        LogUtil.e("Database error: updateWallpaper() failed to open database");
        return;
    }

    if (wallpaper == null) return;

    ContentValues values = new ContentValues();
    if (wallpaper.getSize() > 0) {
        values.put(KEY_SIZE, wallpaper.getSize());
    }

    if (wallpaper.getMimeType() != null) {
        values.put(KEY_MIME_TYPE, wallpaper.getMimeType());
    }

    if (wallpaper.getDimensions() != null) {
        values.put(KEY_WIDTH, wallpaper.getDimensions().getWidth());
        values.put(KEY_HEIGHT, wallpaper.getDimensions().getHeight());
    }

    if (wallpaper.getColor() != 0) {
        values.put(KEY_COLOR, wallpaper.getColor());
    }

    if (values.size() > 0) {
        mDatabase.get().mSQLiteDatabase.update(TABLE_WALLPAPERS,
                values, KEY_URL +" = ?", new String[]{wallpaper.getUrl()});
    }
}
 
开发者ID:danimahardhika,项目名称:wallpaperboard,代码行数:32,代码来源:Database.java

示例7: renameVolume

import android.content.ContentValues; //导入方法依赖的package包/类
public void renameVolume(EDVolume volume, String newName) {
	SQLiteDatabase db = getWritableDatabase();

	Log.d(TAG, "renameVolume() " + volume.getName() + " to " + newName);

	ContentValues values = new ContentValues();
	values.put(DB_COL_NAME, newName);
	db.update(DB_TABLE, values, DB_COL_NAME + "=? AND " + DB_COL_PATH
			+ "=?", new String[] { volume.getName(), volume.getPath() });
	
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:12,代码来源:EDDBHelper.java

示例8: getCV

import android.content.ContentValues; //导入方法依赖的package包/类
public static ContentValues getCV(VKApiVideoAlbum p){
    ContentValues cv = new ContentValues();
    cv.put(OWNER_ID, p.owner_id);
    cv.put(ALBUM_ID, p.id);
    cv.put(TITLE, p.title);
    cv.put(PHOTO_160, p.photo_160);
    cv.put(PHOTO_320, p.photo_320);
    cv.put(COUNT, p.count);
    cv.put(UPDATE_TIME, p.updated_time);
    cv.put(PRIVACY, isNull(p.privacy) ? null : p.privacy.toString());
    return cv;
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:13,代码来源:VideoAlbumsColumns.java

示例9: updateAvatar

import android.content.ContentValues; //导入方法依赖的package包/类
public void updateAvatar(byte[] groupId, byte[] avatar) {
  ContentValues contentValues = new ContentValues();
  contentValues.put(AVATAR, avatar);

  databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues, GROUP_ID +  " = ?",
                                              new String[] {GroupUtil.getEncodedId(groupId)});

  RecipientFactory.clearCache(context);
  notifyDatabaseListeners();
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:11,代码来源:GroupDatabase.java

示例10: addDownload

import android.content.ContentValues; //导入方法依赖的package包/类
public void addDownload(int bookId, long enqueueId, int downloadStatus) {
    //TODO what if the book id already exisited ?
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put(BooksInformationDBContract.StoredBooks.COLUMN_NAME_ENQID, enqueueId);
    contentValues.put(BooksInformationDBContract.StoredBooks.COLUMN_NAME_STATUS, downloadStatus);
    contentValues.put(BooksInformationDBContract.StoredBooks.COLUMN_NAME_BookID, bookId);
    db.insertWithOnConflict(BooksInformationDBContract.StoredBooks.TABLE_NAME,
            null,
            contentValues,
            SQLiteDatabase.CONFLICT_REPLACE);
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:13,代码来源:BooksInformationDbHelper.java

示例11: updateConnectionModel

import android.content.ContentValues; //导入方法依赖的package包/类
@Override
public void updateConnectionModel(int id, int index, long currentOffset) {
    final ContentValues values = new ContentValues();
    values.put(ConnectionModel.CURRENT_OFFSET, currentOffset);
    db.update(CONNECTION_TABLE_NAME, values
            , ConnectionModel.ID + " = ? AND " + ConnectionModel.INDEX + " = ?"
            , new String[]{Integer.toString(id), Integer.toString(index)});
}
 
开发者ID:yannanzheng,项目名称:FileDownloader-master,代码行数:9,代码来源:DefaultDatabaseImpl.java

示例12: insert_users

import android.content.ContentValues; //导入方法依赖的package包/类
public boolean insert_users(String first_name, String last_name, String e_mail, String password, String user, String department){
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put(COL_1, first_name);
    contentValues.put(COL_2, last_name);
    contentValues.put(COL_3, e_mail);
    contentValues.put(COL_4, password);
    contentValues.put(COL_5, user);
    contentValues.put(COL_6, department);
    long result=db.insert(table_user, null, contentValues);
    if(result==-1)
        return false;
    else
        return true;
}
 
开发者ID:JCass45,项目名称:3D5B,代码行数:16,代码来源:DatabaseHelper.java

示例13: add

import android.content.ContentValues; //导入方法依赖的package包/类
/**
 * 添加到本地数据库
 *
 * @param item History
 * @return the row ID of the newly inserted row, or -1 if an error occurred
 */
public long add(History item) {
    ContentValues cv = new ContentValues();
    cv.put(KEY_DATE, item.getDate());
    cv.put(KEY_RESULT, item.getResult());
    cv.put(KEY_TIME, item.getTime());
    cv.put(KEY_IMG, item.getImg());
    cv.put(KEY_UPDATE, item.getDate());
    return getWritableDatabase().insert(TABLE_NAME, KEY_RESULT, cv);
}
 
开发者ID:shenhuanet,项目名称:Ocr-android,代码行数:16,代码来源:HistoryDatabase.java

示例14: addCart

import android.content.ContentValues; //导入方法依赖的package包/类
void addCart(Food food) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_FOOD_NAME_C, food.getName());
    values.put(KEY_FOOD_COST_C, food.getCost());

    // Inserting Row
    db.insert(TABLE_CART, null, values);
    db.close(); // Closing database connection
}
 
开发者ID:omralcrt,项目名称:OrderFood,代码行数:12,代码来源:DatabaseHandler.java

示例15: cancelReminder

import android.content.ContentValues; //导入方法依赖的package包/类
public static void cancelReminder(Context context, long toduleId){
    Uri toduleUri = ContentUris.withAppendedId(ToduleDBContract.TodoEntry.CONTENT_ID_URI_BASE, toduleId);
    PendingIntent pIntent = initReminderPendingIntent(context, toduleUri);
    AlarmManager am = (AlarmManager) context.getSystemService(ALARM_SERVICE);
    am.cancel(pIntent);

    String select = ToduleDBContract.TodoNotification.COLUMN_NAME_TODULE_ID + " = ?";
    String[] selectionArgs = {String.valueOf(toduleId)};

    ContentValues cv = new ContentValues();
    cv.put(ToduleDBContract.TodoNotification.COLUMN_NAME_REMINDER_CANCELED, ToduleDBContract.TodoNotification.REMINDER_CANCELED);
    context.getContentResolver().update(ToduleDBContract.TodoNotification.CONTENT_URI, cv, select, selectionArgs);
}
 
开发者ID:danlls,项目名称:Todule-android,代码行数:14,代码来源:NotificationHelper.java


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