title: multiple variables, cursor or stringarray dilemma
body: <p>i want to populate my userinterface elements with data from my database</p>
  
  <p>reading the database happens over my according database class (AbezoeAdapter)</p>
  
  <p>populating my userinterface is done by my mainclass (Bezoekrapporten)</p>
  
  <p>now i am struggling with following code to get my idea working</p>
  
  <pre><code>package com.example.deceunincktechniekers;
  
  import java.util.Date;
  import java.text.DateFormat;
  import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  
  import android.annotation.SuppressLint;
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.graphics.Point;
  import android.os.Bundle;
  import android.util.Log;
  import android.util.TypedValue;
  import android.view.Display;
  import android.view.Gravity;
  import android.view.KeyEvent;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup.LayoutParams;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.PopupWindow;
  import android.widget.RelativeLayout;
  import android.widget.TextView;
  import android.content.res.*;
  import android.database.Cursor;
  
  @SuppressLint("SimpleDateFormat") public class bezoekrapporten extends Activity
  {
      TextView controlelijn;
      EditText scanzonedata;
  String scanzonestring;
  String sScan;
  String Bezoeknummer;
  
  @Override
  public void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.bezoekrapporten);
  
       //////////////////////// here is some code missing///////////////////////////
  
  
          private void vulbezoekrapportboxin(String bezoeknummer) {
      ABezoeAdapter bezoe = new ABezoeAdapter(this);
  
      TextView bezoekrapportnummer;
      bezoekrapportnummer = (TextView) findViewById(R.id.boxbrBrnum);
  
      TextView servicenummer;
      servicenummer = (TextView) findViewById(R.id.boxbrServicenum);
  
      TextView datum;
      datum = (TextView) findViewById(R.id.boxbrBrdatum);
  
      TextView klantnaam;
      klantnaam = (TextView) findViewById(R.id.boxbrKlant);
  
      TextView straatnaam;
      straatnaam = (TextView) findViewById(R.id.boxbrAdres);
  
      TextView gemeente;
      gemeente = (TextView) findViewById(R.id.boxbrGemeente);
  
      TextView machinenummer;
      machinenummer = (TextView) findViewById(R.id.boxbrMachinenr);
  
      TextView merk;
      merk = (TextView) findViewById(R.id.boxbrMerk);
  
      TextView serienummer;
      serienummer = (TextView) findViewById(R.id.boxbrSerial);
  
      if(bezoeknummer == null)
      {
          bezoekrapportnummer.setText("-----");
  
      }
      else
      {
          Cursor c =bezoe.leesgegevens(bezoeknummer);
  
          if (c.moveToFirst()){
                 while(!c.isAfterLast()){
                    String data = c.getString(c.getColumnIndex("bezoekrapportdatum"));
                    controlelijn.setText(data);
                    c.moveToNext();
                 }
              }
              c.close();
  
          bezoekrapportnummer.setText(bezoeknummer);
  
      }
  
      return;
  
  }
  </code></pre>
  
  <p>and the code snippet from AbezoeAdapter</p>
  
  <pre><code>       package com.example.deceunincktechniekers;
           import android.content.ContentValues;
         import android.content.Context;
        import android.database.Cursor;
         import android.database.SQLException;
       import android.database.sqlite.*;
        import android.util.Log;
  
      public class ABezoeAdapter extends ADbAdapter {
  
  public static final String recordnummer = "RECNUM";
  public static final String bezoekrapportnummer = "Z01";
  public static final String bezoekrapportdatum = "Z02";
  public static final String herstellingsoort = "Z03";
  
  //////////////////here is some code missing///////////////////////////:
  
  public static final String basisservicenummer = "Z27";
  public static final String verzonden = "Z28";
  
  public static final String[] allekolommen = new String[] {bezoekrapportnummer + " AS _id", bezoekrapportdatum, 
      herstellingsoort, totaleduur, servicenummer, ONBEKEND, klantnaam, adres, machinenummer, omschrijving, 
      duur, postcode, gemeente, merk, model, serienummer, opmerkingen, werkgereed, extratijd, urenstand, gecontroleerdbureel,
      onderhoudsfiche, uitsplitsen, opmerkingbureel, ONBEKEND2, orderverwerkdatum, ordernummer, basisservicenummer, verzonden};
  
                  //////////////////////////////here is some code missing/////////////////////////////////////////////
  
      public Cursor leesgegevens(String bezoeknummer) {
          open();
          Cursor c =  onzedatabase.query(true, databasetabel, allekolommen, 
                           "_id" + "=?", new String[] { bezoeknummer }, null, null, null, null, null);
          if (c != null) {
          c.moveToFirst();
          }
          Log.i("cursor leesgegevens", c.toString());
          sluit();
          return c;
  
  
              /////////////////////////////////////here is some code missing//////////////////
  </code></pre>
  
  <p>can anybody inform me with the best way of working to get the data from the database to my UI?</p>
  
  <p>if i am already able to compile my code i get an error in my logcat that looks as follows:</p>
  
  <pre><code>11-24 15:58:34.089: E/AndroidRuntime(785): FATAL EXCEPTION: main
  11-24 15:58:34.089: E/AndroidRuntime(785): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.deceunincktechniekers/com.example.deceunincktechniekers.bezoekrapporten}: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
  </code></pre>