Code example for ContentValues

Methods: putAll

0
	@Override 
	public void addToFavorites(PlaylistEntry entry) {
		SQLiteDatabase db = getDb();
		 
		// put playlistentry data the table 
		ContentValues values = new ContentValues();
		 
		values.putAll(new TrackDatabaseBuilder().deconstruct(entry.getTrack()));
		values.putAll(new AlbumDatabaseBuilder().deconstruct(entry.getAlbum()));
		 
		 
		String[] whereArgs = {""+entry.getTrack().getId()};
		int row_count = db.update(TABLE_FAVORITES, values, "track_id=?", whereArgs);
		 
		if(row_count == 0){
			db.insert(TABLE_FAVORITES, null, values);
		} 
		 
		 
		db.close();
	}