Example usage for android.database.sqlite SQLiteDatabase insert

List of usage examples for android.database.sqlite SQLiteDatabase insert

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteDatabase insert.

Prototype

public long insert(String table, String nullColumnHack, ContentValues values) 

Source Link

Document

Convenience method for inserting a row into the database.

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

private static void insertDataTopic(SQLiteDatabase db, String section, String name, String url,
        int resourceId) {
    ContentValues values = new ContentValues();
    values.put("SECTION", section);
    values.put("NAME", name);
    values.put("URL", url);
    values.put("IMAGE_RESOURCE_ID", resourceId);
    db.insert("TOPIC", null, values);
}

From source file:Main.java

private static void insertToSUJamesWeekends(SQLiteDatabase db, String startStopName, String toStopName,
        int timeGap) {
    ContentValues routevalues = new ContentValues();
    routevalues.put("START_STOP_JAMES_TO_SU", startStopName);
    routevalues.put("TO_STOP", toStopName);
    routevalues.put("TIME_GAP", timeGap);
    db.insert("TOSU_JAMES_WEEKEND", null, routevalues);

}

From source file:Main.java

private static void insertPeople(SQLiteDatabase db, String lastName, String name, String bio, int image_id) {
    ContentValues peopleValues = new ContentValues();
    peopleValues.put("LAST_NAME", lastName);
    peopleValues.put("NAME", name);
    peopleValues.put("BIO", bio);
    peopleValues.put("IMAGE_ID", image_id);
    db.insert("PEOPLE", null, peopleValues);
}

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);/*from w  w  w .  j ava  2s .  c  o m*/
    drinkValues.put(COLUMN_DESCRIPTION, description);
    drinkValues.put(COLUMN_IMAGE_RESOURCE_ID, imageResourceId);

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

From source file:mx.com.adolfogarcia.popularmovies.data.TestUtilities.java

/**
 * Inserts the values returned by {@link #createMadMaxMovieValues()} into
 * the movie database.//  w  w w  .ja v a 2 s. c o m
 *
 * @param context the {@link Context} used to access the database.
 * @return the row id of the insertion.
 */
static long insertMadMaxMovieValues(Context context) {
    MovieDbHelper dbHelper = new MovieDbHelper(context);
    SQLiteDatabase db = dbHelper.getWritableDatabase();
    ContentValues testValues = TestUtilities.createMadMaxMovieValues();

    long rowId;
    rowId = db.insert(CachedMovieEntry.TABLE_NAME, null, testValues);
    Assert.assertTrue("Row was successfully inserted", rowId != -1);
    return rowId;
}

From source file:mx.com.adolfogarcia.popularmovies.data.TestUtilities.java

/**
 * Inserts the values returned by {@link #createMadMaxMovieVideoValues()} into
 * the movie database.// w  w  w . jav a  2  s .c  o m
 *
 * @param context the {@link Context} used to access the database.
 * @return the row id of the insertion.
 */
static long insertMadMaxMovieVideoValues(Context context) {
    MovieDbHelper dbHelper = new MovieDbHelper(context);
    SQLiteDatabase db = dbHelper.getWritableDatabase();
    ContentValues testValues = TestUtilities.createMadMaxMovieVideoValues();

    long rowId;
    rowId = db.insert(CachedMovieVideoEntry.TABLE_NAME, null, testValues);
    Assert.assertTrue("Row was successfully inserted", rowId != -1);
    return rowId;
}

From source file:Main.java

private static void insertDietPlan(SQLiteDatabase db, String dietName, String dietRecipeSteps,
        int dietImageId) {
    ContentValues dietPlanValues = new ContentValues();
    dietPlanValues.put("DIET_NAME", dietName);
    dietPlanValues.put("RECIPE_STEPS", dietRecipeSteps);
    dietPlanValues.put("DIET_IMAGE_ID", dietImageId);
    db.insert("DIETPLAN", null, dietPlanValues);
}

From source file:mx.com.adolfogarcia.popularmovies.data.TestUtilities.java

/**
 * Inserts the values returned by {@link #createMadMaxMovieVideoValues()} into
 * the movie database./*  ww  w  .j  av a  2 s. co  m*/
 *
 * @param context the {@link Context} used to access the database.
 * @return the row id of the insertion.
 */
static long insertMadMaxMovieReviewValues(Context context) {
    MovieDbHelper dbHelper = new MovieDbHelper(context);
    SQLiteDatabase db = dbHelper.getWritableDatabase();
    ContentValues testValues = TestUtilities.createMadMaxMovieReviewValues();

    long rowId;
    rowId = db.insert(CachedMovieReviewEntry.TABLE_NAME, null, testValues);
    Assert.assertTrue("Row was successfully inserted", rowId != -1);
    return rowId;
}

From source file:Main.java

private static void insertDrink(SQLiteDatabase db, String name, String description, int resourceId) { //this method was created to
    ContentValues drinkValues = new ContentValues(); //... insert several drink rows
    drinkValues.put("NAME", name);
    drinkValues.put("DESCRIPTION", description);
    drinkValues.put("image_id", resourceId);
    db.insert("DRINK", null, drinkValues);
}