title: How to get cursor to read next line from SQLite Database?
body: <p>I am trying to get a report from my database from certain fields to an PDF.  The pdf is generating perfectly but it is only reading the first entry from the database instead of all the entries.</p>
  
  <p>This is my code for the PDF:</p>
  
  <pre><code>public void exportDataBaseIntoPDF() {
      Document doc = new Document(PageSize.A4);
      try {
          path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/MSS Jobsheets";
          date = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).format(new Date());
  
          File dir = new File(path);
          if (!dir.exists())
              dir.mkdirs();
  
          Log.d("PDFCreator", "PDF Path: " + path);
  
          filePDF = new File(dir, "Report" + "(" + date + ")" + ".pdf");
          FileOutputStream fOut = null;
          try {
              fOut = new FileOutputStream(filePDF);
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          }
          PdfWriter.getInstance(doc, fOut);
          doc.open();
  
          DBHelper db = new DBHelper(this);
          Cursor cursor = db.getDataItem();
          int count = cursor.getCount();
  
          cursor.moveToFirst();
  
          for (int j = 0; j &lt; count; j++) {
              PdfPTable table = new PdfPTable(2);
              table.addCell(cursor.getString(cursor.getColumnIndex("name")));
              table.addCell(cursor.getString(cursor.getColumnIndex("gender")));
  
  
              cursor.moveToNext();
  
              doc.add(table);
              doc.close();
          }
  
      } catch (DocumentException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>This is pulling the data from my DBHelper class:</p>
  
  <pre><code> public Cursor getDataItem() {
      SQLiteDatabase db = this.getReadableDatabase();
      String q = "SELECT * FROM " + PERSON_TABLE_NAME;
      Cursor mCursor = db.rawQuery(q, null);
  
      return mCursor;
  }
  }
  </code></pre>
  
  <p>But like I said, it only reads the first line from the database and adds the data but does not move on to the next line in the database to add the data in the PDF.</p>
  
  <p>Could some one please assist me with this issue?
  Thanks in advance!</p>