app/src/main/java/com/kevinrei/chronotrack/MySQLiteHelper.java
// Add new details for a specific game
Add new details for a specific game
Add new details for a specific game
public void addGame(Game game) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues values = new ContentValues();
        values.put(KEY_TITLE, game.getTitle());
        values.put(KEY_IMAGE, game.getImage());
        values.put(KEY_CATEGORY, game.getCategory());
        values.put(KEY_UNIT, game.getUnit());
        values.put(KEY_RECOVERY_RATE, game.getRecoveryRate());
        values.put(KEY_MAX_STAMINA, game.getMaxStamina());
        db.insert(TABLE_GAMES, null, values);
        Log.d(TAG_GAME, game.toString());
        db.close();
    }
public void addGame ( Game game ) { SQLiteDatabase db = this . getWritableDatabase ( ) ; ContentValues values = new ContentValues ( ) ; values . put ( KEY_TITLE , game . getTitle ( ) ) ; values . put ( KEY_IMAGE , game . getImage ( ) ) ; values . put ( KEY_CATEGORY , game . getCategory ( ) ) ; values . put ( KEY_UNIT , game . getUnit ( ) ) ; values . put ( KEY_RECOVERY_RATE , game . getRecoveryRate ( ) ) ; values . put ( KEY_MAX_STAMINA , game . getMaxStamina ( ) ) ; db . insert ( TABLE_GAMES , null , values ) ; Log . d ( TAG_GAME , game . toString ( ) ) ; db . close ( ) ; }
Add new details for a specific game
Add new details for a specific game
// Get reference to a writable database // Create ContentValues to add key "column"/value // Insert to database // Close the database