title: trying to display data from my table into listview in android whats wrong?
body: <p>as I mentioned in the title </p>
  
  <p>I am trying to display data from my table into listview but when I open the emulator it stops immediately and I think i have an error nullpointer or something like that .. or I do not really now .. </p>
  
  <p>here is my code:</p>
  
  <h2>JAVA</h2>
  
  <p>MainActivity.java :</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  ListView PersonsList;
  DataBaseAdapter  helper;
  private SimpleCursorAdapter dataAdapter;
  
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      helper = new DataBaseAdapter(this);
  
      displayListView();
  
  }
  
  
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  
  
  private void displayListView() {
  
  
      Cursor cursor = helper.fetchAllPersons();
  
      // The desired columns to be bound
      String[] columns = new String[]{
  
              DataBaseAdapter.Helper.PERSON_NAME,
              DataBaseAdapter.Helper.GENDER,
      };
  
      // the XML defined views which the data will be bound to
      int[] to = new int[]{
              R.id.personName,
              R.id.personGender,
  
      };
  
      // create the adapter using the cursor pointing to the desired data
      //as well as the layout information
      dataAdapter = new SimpleCursorAdapter(
              this, R.layout.single_person_item,
              cursor,
              columns,
              to,
              0);
  
      PersonsList = (ListView) findViewById(R.id.personsListView);
      PersonsList.setAdapter(dataAdapter);
   }
   }
  </code></pre>
  
  <p>fetcAllPpersons() in DataBaseAdapter.java ::</p>
  
  <pre><code>   public Cursor fetchAllPersons() {
  
      SQLiteDatabase db = helper.getWritableDatabase();
  
      Cursor mCursor = db.query(Helper.PERSONS_TABLE, new String[]     {Helper.PERSON_ID,Helper.PERSON_NAME,Helper.DATE_OF_BIRTH,Helper.GENDER,Helper.ADDRESS},
              null, null, null, null, null);
  
      if (mCursor != null) {
          mCursor.moveToFirst();
      }
      return mCursor;
  }
  </code></pre>
  
  <hr>
  
  <p>xml:</p>
  
  <p>activity_main.xml:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"      android:layout_width="match_parent"
  android:layout_height="match_parent"    android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
  &gt;
  
  
  &lt;ScrollView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/scrollView2"
      android:layout_below="@+id/addnewperson"
      android:layout_alignLeft="@+id/addnewperson"
      android:layout_alignStart="@+id/addnewperson"&gt;
  
    &lt;ListView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/personsListView"
      android:layout_below="@+id/scrollView2"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true" /&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p></p>
  
  <p>single_person_item.xml :</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical"
  android:padding="6dip" &gt;
  
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceMedium"
      android:text="Medium Text"
      android:id="@+id/personName" /&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceMedium"
      android:text="Medium Text"
      android:id="@+id/personGender" /&gt;
   &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>where PERSONS_TABLE is the table i want to show some infromation from </p>
  
  <p>where is the problem ?? </p>
  
  <p>( the problem is most likely here : </p>
  
  <pre><code>   dataAdapter = new SimpleCursorAdapter(
          this, R.layout.single_person_item,
          cursor,
          columns,
          to,
          0);
  </code></pre>
  
  <p>)</p>
  
  <p>but i can not detect it
  thx in advance</p>