Hallo an Alle,
ich versuche, in meiner App, Daten aus einer Tabelle mittels rawQuery zu lesen. Der Code sieht wie folgt aus:
GesundheitOpenHandler.java
public class GesundheitOpenHandler extends SQLiteOpenHelper {
...
public Cursor kw_query(String string, String[] parms){
// ggf. Datenbank öffnen
SQLiteDatabase db = getWritableDatabase();
return db.rawQuery(string, parms);
}
...
}
Plot_XY_Activity.java
public class Plot_XY_Activity extends Activity
{
...
sql = bundle.getString("sql"); //sql = "select gew_gewicht from tbl_gewicht where gew_kw =";
kw = bundle.getString("kw");
String[] parms = {kw};
setTitle(titel);
Log.w(TAG,sql + " ; " + parms[0]);
Cursor c = openhandler.kw_query(sql, parms); <====== Fehler
...
}
Alles anzeigen
Im LogCat steht folgendes
05-09 23:48:12.175: W/Plot_XY_Activity(599): select gew_gewicht from tbl_gewicht where gew_kw = ; 19
05-09 23:48:12.224: D/AndroidRuntime(599): Shutting down VM
05-09 23:48:12.224: W/dalvikvm(599): threadid=1: thread exiting with uncaught exception (group=0x40015560)
05-09 23:48:12.234: E/AndroidRuntime(599): FATAL EXCEPTION: main
05-09 23:48:12.234: E/AndroidRuntime(599): java.lang.RuntimeException: Unable to start activity ComponentInfo{my.app.gesundheit/my.app.gesundheit.Plot_XY_Activity}: java.lang.NullPointerException
05-09 23:48:12.234: E/AndroidRuntime(599): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-09 23:48:12.234: E/AndroidRuntime(599): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-09 23:48:12.234: E/AndroidRuntime(599): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-09 23:48:12.234: E/AndroidRuntime(599): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-09 23:48:12.234: E/AndroidRuntime(599): at android.os.Handler.dispatchMessage(Handler.java:99)
05-09 23:48:12.234: E/AndroidRuntime(599): at android.os.Looper.loop(Looper.java:123)
05-09 23:48:12.234: E/AndroidRuntime(599): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-09 23:48:12.234: E/AndroidRuntime(599): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 23:48:12.234: E/AndroidRuntime(599): at java.lang.reflect.Method.invoke(Method.java:507)
05-09 23:48:12.234: E/AndroidRuntime(599): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-09 23:48:12.234: E/AndroidRuntime(599): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-09 23:48:12.234: E/AndroidRuntime(599): at dalvik.system.NativeStart.main(Native Method)
05-09 23:48:12.234: E/AndroidRuntime(599): Caused by: java.lang.NullPointerException
05-09 23:48:12.234: E/AndroidRuntime(599): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:63)
05-09 23:48:12.234: E/AndroidRuntime(599): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
05-09 23:48:12.234: E/AndroidRuntime(599): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
05-09 23:48:12.234: E/AndroidRuntime(599): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1356)
05-09 23:48:12.234: E/AndroidRuntime(599): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1324)
05-09 23:48:12.234: E/AndroidRuntime(599): at my.app.gesundheit.GesundheitOpenHandler.kw_query(GesundheitOpenHandler.java:100)
05-09 23:48:12.234: E/AndroidRuntime(599): at my.app.gesundheit.Plot_XY_Activity.onCreate(Plot_XY_Activity.java:55)
05-09 23:48:12.234: E/AndroidRuntime(599): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-09 23:48:12.234: E/AndroidRuntime(599): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
Ich weiss nicht, warum das Programm an dieser Stelle abbricht. Hat jemand von Euch Tipps oder Hinweise zur Fehlerbeseitigung?
Bis dann ...
Günter