mardi 10 mars 2015

The bind value at index 1 is null after clicking ScrollView

I have created a film database app where the user can search for a film and the results will display in a ScrollView. I have then made this scrollView clickable, so a user can click on a film which will lead to another activity displaying all of the details of that film. However when I click the film result, I get this error. Any idea why?


Code:



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[] columns = {"*"};
String where = "id=?";
String[] selArgs = {filmID};
Cursor film = db.query("FILMTABLE", columns, where, selArgs, null, null, null);

film.moveToNext();
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();


}


}


Logcat:



java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mnt.filmapp6/com.mnt.filmapp6.MainActivity4}: java.lang.IllegalArgumentException: the bind value at index 1 is null
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.IllegalArgumentException: the bind value at index 1 is null
at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:164)
at android.database.sqlite.SQLiteProgram.bindAllArgsAsStrings(SQLiteProgram.java:200)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1163)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1034)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1240)
at com.mnt.filmapp6.MainActivity4.onCreate(MainActivity4.java:33)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Aucun commentaire:

Enregistrer un commentaire