Search in sources :

Example 1 with ContentValues

use of android.content.ContentValues in project android-job by evernote.

the class DatabaseUpgradeTest method createJobs.

private void createJobs(UpgradeAbleJobOpenHelper openHelper) {
    SQLiteDatabase database = openHelper.getWritableDatabase();
    ContentValues contentValues = openHelper.createBaseContentValues(1);
    contentValues.put(JobStorage.COLUMN_START_MS, 60_000L);
    contentValues.put(JobStorage.COLUMN_END_MS, 120_000L);
    database.insert(JobStorage.JOB_TABLE_NAME, null, contentValues);
    contentValues = openHelper.createBaseContentValues(2);
    contentValues.put(JobStorage.COLUMN_INTERVAL_MS, 60_000L);
    database.insert(JobStorage.JOB_TABLE_NAME, null, contentValues);
    contentValues = openHelper.createBaseContentValues(3);
    contentValues.put(JobStorage.COLUMN_INTERVAL_MS, TimeUnit.MINUTES.toMillis(20));
    database.insert(JobStorage.JOB_TABLE_NAME, null, contentValues);
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 2 with ContentValues

use of android.content.ContentValues in project cw-omnibus by commonsguy.

the class ConstantsFragment method onClick.

public void onClick(DialogInterface di, int whichButton) {
    ContentValues values = new ContentValues(2);
    AlertDialog dlg = (AlertDialog) di;
    EditText title = (EditText) dlg.findViewById(R.id.title);
    EditText value = (EditText) dlg.findViewById(R.id.value);
    values.put(DatabaseHelper.TITLE, title.getText().toString());
    values.put(DatabaseHelper.VALUE, value.getText().toString());
    task = new InsertTask().execute(values);
}
Also used : ContentValues(android.content.ContentValues) AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText)

Example 3 with ContentValues

use of android.content.ContentValues in project cw-omnibus by commonsguy.

the class ConstantsBrowser method processAdd.

private void processAdd(DialogWrapper wrapper) {
    ContentValues values = new ContentValues(2);
    values.put(Provider.Constants.TITLE, wrapper.getTitle());
    values.put(Provider.Constants.VALUE, wrapper.getValue());
    getContentResolver().insert(Provider.Constants.CONTENT_URI, values);
}
Also used : ContentValues(android.content.ContentValues)

Example 4 with ContentValues

use of android.content.ContentValues in project cw-omnibus by commonsguy.

the class DatabaseHelper method onCreate.

@Override
public void onCreate(SQLiteDatabase db) {
    Cursor c = db.rawQuery("SELECT name FROM sqlite_master WHERE type='table' AND name='constants'", null);
    try {
        if (c.getCount() == 0) {
            db.execSQL("CREATE TABLE constants (_id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, value REAL);");
            ContentValues cv = new ContentValues();
            cv.put(Provider.Constants.TITLE, "Gravity, Death Star I");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_DEATH_STAR_I);
            db.insert("constants", Provider.Constants.TITLE, cv);
            cv.put(Provider.Constants.TITLE, "Gravity, Earth");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_EARTH);
            db.insert("constants", Provider.Constants.TITLE, cv);
            cv.put(Provider.Constants.TITLE, "Gravity, Jupiter");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_JUPITER);
            db.insert("constants", Provider.Constants.TITLE, cv);
            cv.put(Provider.Constants.TITLE, "Gravity, Mars");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_MARS);
            db.insert("constants", Provider.Constants.TITLE, cv);
            cv.put(Provider.Constants.TITLE, "Gravity, Mercury");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_MERCURY);
            db.insert("constants", Provider.Constants.TITLE, cv);
            cv.put(Provider.Constants.TITLE, "Gravity, Moon");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_MOON);
            db.insert("constants", Provider.Constants.TITLE, cv);
            cv.put(Provider.Constants.TITLE, "Gravity, Neptune");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_NEPTUNE);
            db.insert("constants", Provider.Constants.TITLE, cv);
            cv.put(Provider.Constants.TITLE, "Gravity, Pluto");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_PLUTO);
            db.insert("constants", Provider.Constants.TITLE, cv);
            cv.put(Provider.Constants.TITLE, "Gravity, Saturn");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_SATURN);
            db.insert("constants", Provider.Constants.TITLE, cv);
            cv.put(Provider.Constants.TITLE, "Gravity, Sun");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_SUN);
            db.insert("constants", Provider.Constants.TITLE, cv);
            cv.put(Provider.Constants.TITLE, "Gravity, The Island");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_THE_ISLAND);
            db.insert("constants", Provider.Constants.TITLE, cv);
            cv.put(Provider.Constants.TITLE, "Gravity, Uranus");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_URANUS);
            db.insert("constants", Provider.Constants.TITLE, cv);
            cv.put(Provider.Constants.TITLE, "Gravity, Venus");
            cv.put(Provider.Constants.VALUE, SensorManager.GRAVITY_VENUS);
            db.insert("constants", Provider.Constants.TITLE, cv);
        }
    } finally {
        c.close();
    }
}
Also used : ContentValues(android.content.ContentValues) Cursor(android.database.Cursor)

Example 5 with ContentValues

use of android.content.ContentValues in project cw-omnibus by commonsguy.

the class ConstantsBrowser method processAdd.

private void processAdd(DialogWrapper wrapper) {
    ContentValues values = new ContentValues(2);
    values.put(Provider.Constants.TITLE, wrapper.getTitle());
    values.put(Provider.Constants.VALUE, wrapper.getValue());
    getContentResolver().insert(Provider.Constants.CONTENT_URI, values);
}
Also used : ContentValues(android.content.ContentValues)

Aggregations

ContentValues (android.content.ContentValues)3993 Cursor (android.database.Cursor)720 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)638 Uri (android.net.Uri)619 Test (org.junit.Test)374 SQLException (android.database.SQLException)231 ContentResolver (android.content.ContentResolver)212 ArrayList (java.util.ArrayList)192 Intent (android.content.Intent)162 File (java.io.File)156 IOException (java.io.IOException)131 RemoteException (android.os.RemoteException)96 CursorAssert.assertThatCursor (org.hisp.dhis.android.core.data.database.CursorAssert.assertThatCursor)91 NonNull (android.support.annotation.NonNull)74 Date (java.util.Date)73 MediumTest (android.test.suitebuilder.annotation.MediumTest)63 HashMap (java.util.HashMap)62 JSONException (org.json.JSONException)60 SQLiteException (android.database.sqlite.SQLiteException)53 ContentProviderOperation (android.content.ContentProviderOperation)49