0

i have stored my values in the database as followes:

"CREATE TABLE " + 
        ABezoeAdapter.databasetabel + "(" +
        ABezoeAdapter.recordnummer + " INTEGER, " +
        ABezoeAdapter.bezoekrapportnummer + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
        ABezoeAdapter.bezoekrapportdatum + " DATETIME NOT NULL, " +
        ABezoeAdapter.herstellingsoort + " VARCHAR(1) NOT NULL, " +

but this gives me problems with following reading routine

Cursor c = onzedatabase.query(databasetabel, allekolommen, bezoekrapportnummer + "=?", new String[] {bezoeknummer}, null, null, null);

        int i = 0;
        String data[] = new String[30];
        data = null;
        for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){
            data[i] = c.getString(i);
            Log.i("abezoeadapter gegevenslezenvanbezoeknummer", "bezoeknummer = " + data[2]);
        }

out of the logcat i think i get a problem because my values are stored as integer, string, ...

logcat:

03-24 18:36:06.321: E/AndroidRuntime(785): FATAL EXCEPTION: main
03-24 18:36:06.321: E/AndroidRuntime(785): java.lang.RuntimeException: Unable to start activity      ComponentInfo{com.example.deceunincktechniekers/com.example.deceunincktechniekers.bezoekrapporten}:     java.lang.NullPointerException
03-24 18:36:06.321: E/AndroidRuntime(785):  at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-24 18:36:06.321: E/AndroidRuntime(785):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-24 18:36:06.321: E/AndroidRuntime(785):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-24 18:36:06.321: E/AndroidRuntime(785):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-24 18:36:06.321: E/AndroidRuntime(785):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-24 18:36:06.321: E/AndroidRuntime(785):  at android.os.Looper.loop(Looper.java:137)
03-24 18:36:06.321: E/AndroidRuntime(785):  at android.app.ActivityThread.main(ActivityThread.java:5041)
03-24 18:36:06.321: E/AndroidRuntime(785):  at java.lang.reflect.Method.invokeNative(Native Method)
03-24 18:36:06.321: E/AndroidRuntime(785):  at java.lang.reflect.Method.invoke(Method.java:511)
03-24 18:36:06.321: E/AndroidRuntime(785):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-24 18:36:06.321: E/AndroidRuntime(785):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-24 18:36:06.321: E/AndroidRuntime(785):  at dalvik.system.NativeStart.main(Native Method)
03-24 18:36:06.321: E/AndroidRuntime(785): Caused by: java.lang.NullPointerException
03-24 18:36:06.321: E/AndroidRuntime(785):  at com.example.deceunincktechniekers.ABezoeAdapter.gegevenslezenvanbezoeknummer(ABezoeAdapter.java:480)
03-24 18:36:06.321: E/AndroidRuntime(785):  at com.example.deceunincktechniekers.bezoekrapporten.opslaan(bezoekrapporten.java:784)

what can be the solution for my different type of values internet searches didnt helped me out so far

thanks in advance

1 Answer 1

3
String data[] = new String[30];
data = null;

You assign data to null and then try to assign values to it. Hence the NPE. Remove the data = null.

To deal with variable number of entries, consider using e.g. an ArrayList<String> instead of String[].

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.