private ArrayList<Film> creaListaFilm(String categoria) { ArrayList<Film> lista = new ArrayList<Film>(); DbAdapterFilm dbHelper; Cursor cursor; Log.d("creaListaFilm", "sto per fare la roba sul bd"); dbHelper = new DbAdapterFilm(getApplicationContext()); Log.d("creaListaFilm", "apro il bd"); dbHelper.open(); Log.d("creaListaFilm", "ho aperto il bd"); Log.d("creaListaFilm", "riempio il cursore"); cursor = dbHelper.fetchContactsByFilter(categoria); Log.d("creaListaFilm", "selezionata la categoria " + categoria); int i = 0; while (cursor.moveToNext()) { lista.add( new Film( cursor.getInt(cursor.getColumnIndex(DbAdapterFilm.KEY_CONTACTID)), cursor.getString(cursor.getColumnIndex(DbAdapterFilm.KEY_TITLE)), cursor.getString(cursor.getColumnIndex(DbAdapterFilm.KEY_CATEGORY)), cursor.getInt(cursor.getColumnIndex(DbAdapterFilm.KEY_POINT)), cursor.getInt(cursor.getColumnIndex(DbAdapterFilm.KEY_IMAGE)), cursor.getString(cursor.getColumnIndex(DbAdapterFilm.KEY_NAMEIMAGE)), cursor.getString(cursor.getColumnIndex(DbAdapterFilm.KEY_GUESS)))); Log.d("creaListaFilm", lista.get(i).toString()); i++; } cursor.close(); dbHelper.close(); return lista; }
private void updateFilm() { DbAdapterFilm dbHelper; dbHelper = new DbAdapterFilm(getApplicationContext()); dbHelper.open(); dbHelper.updateContact( film.getId(), film.getTitle(), film.getCategory(), film.getPoint(), film.getImage(), film.getNameImage(), film.getTitle()); dbHelper.close(); }