I have created a film database app where a user can search for a film, which will then display in a scrollView, the user can click on their search results and click a button to add this to a favourites list. I have the above error on my cursor query, which is set under my onClick method for my favourites button.
Any idea why I have this error? The error appears on 'Cursor c db.query' line.
public class MainActivity4 extends ActionBarActivity {
String filmId;
SQLiteDatabase db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.details);
Intent intent = getIntent();
filmId= intent.getStringExtra(MainActivity.FILM_ID_KEY);
TextView txtFilm = (TextView) findViewById(R.id.txtFilm);
TextView txtActor = (TextView) findViewById(R.id.txtActor);
TextView txtActor2 = (TextView) findViewById(R.id.txtActor2);
TextView txtDirector = (TextView) findViewById(R.id.txtDirector);
TextView txtDescription = (TextView) findViewById(R.id.txtDescription);
db = new DbHelper(this).getReadableDatabase();
String[] column = {"*"};
String where = "id=?";
String[] selArgs = {filmId};
Cursor film = db.query("FILMTABLE", column, where, selArgs, null, null, null);
film.moveToFirst();
txtFilm.setText(film.getString(film.getColumnIndex("film")));
txtActor.setText(film.getString(film.getColumnIndex("actor")));
txtActor2.setText(film.getString(film.getColumnIndex("actor2")));
txtDirector.setText(film.getString(film.getColumnIndex("director")));
txtDescription.setText(film.getString(film.getColumnIndex("description")));
db.close();
public void AddFav(View v){
db = new DbHelper(this).getWritableDatabase();
Cursor c = db.query ("SELECT FAVOURITE FROM FILMTABLE WHERE id=" + filmId, null);
ContentValues cv = new ContentValues();
cv.put("FAVOURITE", 1);
String where = "id=?";
String[] selArgs = {filmId};
db.update("FILMTABLE", cv, where, selArgs);
}
}
Aucun commentaire:
Enregistrer un commentaire