Example usage for android.content ContentValues put

List of usage examples for android.content ContentValues put

Introduction

In this page you can find the example usage for android.content ContentValues put.

Prototype

public void put(String key, byte[] value) 

Source Link

Document

Adds a value to the set.

Usage

From source file:Main.java

public static void insertPlayer(SQLiteDatabase db, String fio, int teamId, String info, int number) {
    ContentValues playerValues = new ContentValues();

    playerValues.put("FIO", fio);
    playerValues.put("TEAM_id", teamId);
    playerValues.put("INFO", info);
    playerValues.put("NUMBER", number);

    db.insert("PLAYERS", null, playerValues);

}

From source file:Main.java

public static void shiftTableIds(HashMap<String, ArrayList<ContentValues>> operationMap, String tableName,
        String idColumnName, long topTableId) {
    ArrayList<ContentValues> restoreOperations = operationMap.get(tableName);
    if (null == restoreOperations) {
        return;/*from  w  ww  .j  a  va  2s . c om*/
    }
    for (ContentValues restoreCv : restoreOperations) {
        restoreCv.put(idColumnName, restoreCv.getAsLong(idColumnName) + topTableId);
    }
}

From source file:Main.java

private static void insertDrink(SQLiteDatabase db, String name, String description, int imageResourceId) {

    ContentValues drinkValues = new ContentValues();

    drinkValues.put(COLUMN_NAME, name);
    drinkValues.put(COLUMN_DESCRIPTION, description);
    drinkValues.put(COLUMN_IMAGE_RESOURCE_ID, imageResourceId);

    db.insert(TABLE_DRINK, null, drinkValues);
}

From source file:Main.java

/**
 * Adds the saved image to the gallery//from   ww w.j  av  a  2 s .  c  o m
 *
 * From: http://stackoverflow.com/a/20859733
 * @param filePath
 * @param context
 */
public static void addImageToGallery(final String filePath, final Context context) {

    ContentValues values = new ContentValues();

    values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis());
    values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
    values.put(MediaStore.MediaColumns.DATA, filePath);

    context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
}

From source file:Main.java

public static void insertCompany(SQLiteDatabase db, String name, String email, String password, String phone,
        String address) {//from  w w w.j  av a2  s.  c  o  m
    ContentValues companyValues = new ContentValues();
    companyValues.put("NAME", name);
    companyValues.put("EMAIL", email);
    companyValues.put("PASSWORD", password);
    companyValues.put("PHONE", phone);
    companyValues.put("ADDRESS", address);
    companyValues.put("ACTIVO", "ACTIVO");

    db.insert("COMPANY", null, companyValues);
}

From source file:Main.java

public static void insertPlaceholderCall(ContentResolver contentResolver, String name, String number) {
    ContentValues values = new ContentValues();
    values.put(CallLog.Calls.NUMBER, number);
    values.put(CallLog.Calls.DATE, System.currentTimeMillis());
    values.put(CallLog.Calls.DURATION, 0);
    values.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE);
    values.put(CallLog.Calls.NEW, 1);/*from   w  ww  . j  a v  a  2s  .c  o  m*/
    values.put(CallLog.Calls.CACHED_NAME, name);
    values.put(CallLog.Calls.CACHED_NUMBER_TYPE, 0);
    values.put(CallLog.Calls.CACHED_NUMBER_LABEL, "");
    Log.d("Call Log", "Inserting call log placeholder for " + number);
    contentResolver.insert(CallLog.Calls.CONTENT_URI, values);
}

From source file:Main.java

public static void insertContainer(SQLiteDatabase db, String nameContainer, String latlong,
        String establishmentName, String companyName, String estado, String activo, String waste) {
    ContentValues containerValues = new ContentValues();
    containerValues.put("NAME_CONTAINER", nameContainer);
    containerValues.put("LATLONG", latlong);
    containerValues.put("ESTABLISHMENT", establishmentName);
    containerValues.put("COMPANY", companyName);
    containerValues.put("ESTADO", estado);
    containerValues.put("ACTIVO", activo);
    containerValues.put("WASTE", waste);
    db.insert("CONTAINER", null, containerValues);
}

From source file:Main.java

public static void insertImage2MediaStore(Context context, String path) {
    File f = new File(path);
    if (f != null && f.exists()) {
        ContentValues values = new ContentValues();
        values.put(Media.DISPLAY_NAME, f.getName());
        values.put(Media.DESCRIPTION, f.getName());
        values.put(Media.MIME_TYPE, "image/jpeg");
        values.put(Media.DATA, path);

        Uri uri = context.getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
    }//from ww w.  jav a 2s .  c om
}

From source file:Main.java

private static void insertDisease(SQLiteDatabase db, String diseaseName, String diseaseSymptoms,
        String diseaseOverview, String diseaseExpectations, String diseaseRiskFactors, String diseaseTreatment,
        String diseaseSelfCare, String diseaseMAdeWorseBy) {
    ContentValues diseaseValues = new ContentValues();
    diseaseValues.put("NAME", diseaseName);
    diseaseValues.put("SYMPTOMS", diseaseSymptoms);
    diseaseValues.put("OVERVIEW", diseaseOverview);
    diseaseValues.put("EXPECTATIONS", diseaseExpectations);
    diseaseValues.put("RISKFACTORS", diseaseRiskFactors);
    diseaseValues.put("TREATMENT", diseaseTreatment);
    diseaseValues.put("SELFCARE", diseaseSelfCare);
    diseaseValues.put("MADEWORSEBY", diseaseMAdeWorseBy);
    db.insert("DISEASE", null, diseaseValues);
}

From source file:Main.java

public static void insertEstablishment(SQLiteDatabase db, String name, String email, String password,
        String phone, String address, String waste) {
    ContentValues establishmentValues = new ContentValues();
    establishmentValues.put("NAME", name);
    establishmentValues.put("EMAIL", email);
    establishmentValues.put("PASSWORD", password);
    establishmentValues.put("PHONE", phone);
    establishmentValues.put("ADDRESS", address);
    establishmentValues.put("WASTE", waste);
    establishmentValues.put("ACTIVO", "ACTIVO");
    db.insert("ESTABLISHMENT", null, establishmentValues);
}