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:net.ccghe.emocha.model.DBAdapter.java

public static int clean() {
    ContentValues values = new ContentValues();
    values.put("to_download", 0);

    return sDB.update(TABLE_DOWNLOADS, values, null, null);
}

From source file:Main.java

public static ArrayList<ContentValues> getArea(SQLiteDatabase db, int dqx_dqxx01) {
    ArrayList<ContentValues> list = new ArrayList<ContentValues>();
    ContentValues values = null;
    Cursor cursor = db.query(TABLE_NAME, new String[] { "DQXX01", "DQXX02", "DQXX05" }, "DQX_DQXX01=?",
            new String[] { "" + dqx_dqxx01 }, null, null, "DQXX01 ASC");
    if (cursor != null) {
        while (cursor.moveToNext()) {
            values = new ContentValues();
            values.put("area_id", cursor.getInt(0));
            values.put("area", cursor.getString(1));
            values.put("full_area", cursor.getString(2));
            list.add(values);//from  w  w w  .jav  a2  s . com
        }
    }
    if (cursor != null && !cursor.isClosed()) {
        cursor.close();
    }
    return list;
}

From source file:com.lightydev.dk.json.Json.java

public static ContentValues parseObject(JSONObject object, Map<String, String> projection)
        throws JSONException {
    final ContentValues values = new ContentValues();
    for (final Map.Entry<String, String> entry : projection.entrySet()) {
        if (object.has(entry.getValue())) {
            if (object.isNull(entry.getValue())) {
                values.putNull(entry.getKey());
            } else {
                values.put(entry.getKey(), String.valueOf(object.get(entry.getValue())));
            }//www .ja  va  2s.  c o m
        }
    }
    return values;
}

From source file:net.ccghe.emocha.model.DBAdapter.java

private static ContentValues getValues(long ts, long size, String md5, boolean delete, boolean download) {
    ContentValues values = new ContentValues();
    values.put("ts", ts);
    values.put("size", size);
    values.put("md5", md5);
    values.put("to_delete", delete ? 1 : 0);
    values.put("to_download", download ? 1 : 0);
    return values;
}

From source file:net.ccghe.emocha.model.DBAdapter.java

public static void markAsDownloaded(FileInfo file) {
    ContentValues values = new ContentValues();
    values.put("to_download", 0);

    int affected = sDB.update(TABLE_DOWNLOADS, values,
            "path='" + file.path() + "' AND md5='" + file.md5() + "'", null);

    Log.i(Constants.LOG_TAG, "Mark as downloaded: " + file.path() + " (" + file.md5() + ") " + affected);
}

From source file:za.co.neilson.alarm.database.Database.java

public static int update(Alarm alarm) {
    ContentValues cv = new ContentValues();
    cv.put(COLUMN_ALARM_ACTIVE, alarm.getAlarmActive());
    cv.put(COLUMN_ALARM_TIME, alarm.getAlarmTimeString());

    try {// www.j  av  a2  s  . c o  m
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = null;
        oos = new ObjectOutputStream(bos);
        oos.writeObject(alarm.getDays());
        byte[] buff = bos.toByteArray();

        cv.put(COLUMN_ALARM_DAYS, buff);

    } catch (Exception e) {
    }

    cv.put(COLUMN_ALARM_DIFFICULTY, alarm.getDifficulty().ordinal());
    cv.put(COLUMN_ALARM_TONE, alarm.getAlarmTonePath());
    cv.put(COLUMN_ALARM_VIBRATE, alarm.getVibrate());
    cv.put(COLUMN_ALARM_NAME, alarm.getAlarmName());

    return getDatabase().update(ALARM_TABLE, cv, "_id=" + alarm.getId(), null);
}

From source file:za.co.neilson.alarm.database.Database.java

public static long create(Alarm alarm) {
    ContentValues cv = new ContentValues();
    cv.put(COLUMN_ALARM_ACTIVE, alarm.getAlarmActive());
    cv.put(COLUMN_ALARM_TIME, alarm.getAlarmTimeString());

    try {//from ww w . j a v  a2  s  .  c om
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = null;
        oos = new ObjectOutputStream(bos);
        oos.writeObject(alarm.getDays());
        byte[] buff = bos.toByteArray();
        cv.put(COLUMN_ALARM_DAYS, buff);

    } catch (Exception e) {
    }
    Log.v("Alarm Active : ", "" + alarm.getAlarmActive());
    Log.v("Alarm Name : ", "" + alarm.getAlarmName());

    cv.put(COLUMN_ALARM_DIFFICULTY, alarm.getDifficulty().ordinal());
    cv.put(COLUMN_ALARM_TONE, alarm.getAlarmTonePath());
    cv.put(COLUMN_ALARM_VIBRATE, alarm.getVibrate());
    cv.put(COLUMN_ALARM_NAME, alarm.getAlarmName());

    return getDatabase().insert(ALARM_TABLE, null, cv);
}

From source file:net.ccghe.emocha.model.DBAdapter.java

public static long insertFilesNewerThan(Long lastUploadTimestamp, ArrayList<FileInfo> sdcardFiles) {

    Long newUploadTimeStamp = lastUploadTimestamp;
    for (FileInfo sdcardFile : sdcardFiles) {
        if (sdcardFile.lastModified() > lastUploadTimestamp) {
            ContentValues values = new ContentValues(3);
            values.put("path", sdcardFile.path());
            values.put("ts", sdcardFile.lastModified());
            values.put("size", sdcardFile.length());
            sDB.insert(TABLE_UPLOADS, null, values);

            newUploadTimeStamp = Math.max(newUploadTimeStamp, sdcardFile.lastModified());
        }/*  w  w w  .j  av  a2  s .  c om*/
    }
    return newUploadTimeStamp;
}

From source file:com.example.orangeweather.JSONWeatherParser.java

public static HashMap<String, ContentValues> getWeather3(JSONObject jObj) throws JSONException {
    ContentValues cvWeather = new ContentValues();
    ContentValues cvCity = new ContentValues();

    JSONObject coordObj = getObject("coord", jObj);
    cvCity.put(CityTags.CITY_NAME, getString("name", jObj));
    cvCity.put("_id", getInt("id", jObj));
    cvWeather.put("_id", getInt("id", jObj));
    cvWeather.put(WeatherTags.WEATHER_DT, getInt("dt", jObj));
    cvCity.put(CityTags.CITY_COORD, getDMSCoordinates(getFloat("lat", coordObj), getFloat("lon", coordObj)));

    JSONObject sysObj = getObject("sys", jObj);
    cvCity.put(CityTags.CITY_SYS_COUNTRY, getString("country", sysObj));

    if (sysObj.has("sunrise")) {
        cvWeather.put(WeatherTags.WEATHER_SYS_SUNRISE, getInt("sunrise", sysObj));
    }/* ww w.j ava 2s  .c  o m*/
    if (sysObj.has("sunset")) {
        cvWeather.put(WeatherTags.WEATHER_SYS_SUNSET, getInt("sunset", sysObj));
    }

    JSONArray jArr = jObj.getJSONArray("weather");

    JSONObject JSONWeather = jArr.getJSONObject(0);

    cvWeather.put(WeatherTags.WEATHER_CONDITION_DESC, getString("description", JSONWeather));
    cvWeather.put(WeatherTags.WEATHER_CONDITION_MAIN, getString("main", JSONWeather));

    JSONObject mainObj = getObject("main", jObj);
    cvWeather.put(WeatherTags.WEATHER_MAIN_HUMIDITY, getInt("humidity", mainObj));
    cvWeather.put(WeatherTags.WEATHER_MAIN_PRESSURE, getInt("pressure", mainObj));
    cvWeather.put(WeatherTags.WEATHER_MAIN_TEMP_MAX, getTemperatureString(getFloat("temp_max", mainObj)));
    cvWeather.put(WeatherTags.WEATHER_MAIN_TEMP_MIN, getTemperatureString(getFloat("temp_min", mainObj)));
    cvWeather.put(WeatherTags.WEATHER_MAIN_TEMP, getTemperatureString(getFloat("temp", mainObj)));

    JSONObject wObj = getObject("wind", jObj);
    cvWeather.put(WeatherTags.WEATHER_WIND_SPEED, getFloat("speed", wObj));
    cvWeather.put(WeatherTags.WEATHER_WIND_DEG, getInt("deg", wObj));

    if (wObj.has("var_beg")) {
        cvWeather.put(WeatherTags.WEATHER_WIND_VAR_BEG, getInt("var_beg", wObj));
    }
    if (wObj.has("var_end")) {
        cvWeather.put(WeatherTags.WEATHER_WIND_VAR_END, getInt("var_end", wObj));
    }

    JSONObject cObj = getObject("clouds", jObj);
    cvWeather.put(WeatherTags.WEATHER_CLOUDS_ALL, getInt("all", cObj));
    HashMap<String, ContentValues> hm = new HashMap<String, ContentValues>();
    hm.put(CityTags.OBJECT_TAG, cvCity);
    hm.put(WeatherTags.OBJECT_TAG, cvWeather);
    return hm;
}

From source file:net.ccghe.emocha.model.DBAdapter.java

public static long insertFile(String path, long ts, long size, String md5, boolean delete, boolean download) {
    ContentValues values = getValues(ts, size, md5, delete, download);
    values.put("path", path);
    return sDB.insert(TABLE_DOWNLOADS, null, values);
}