title: SQLite- button adds value to db.query
body: <p>I've got a database with the following columns:</p>
  
  <p><code>Book_name</code>, <code>book_id</code>, <code>chapter_number</code>, <code>chapter_id</code>, <code>line_number</code>, <code>line_id</code></p>
  
  <p>I'm doing this app to read books, select a chapter to read, and then display all the lines.</p>
  
  <p>First <code>listview</code> displays all the books, when the user selects on a book name, it passes the book_id to display all the chapters under that book, when selecting a chapter, it passes the <code>chapter_id</code> to display all the lines under that chapter.</p>
  
  <p>My question is, when a user is busy reading they must press the back button to display all the chapters again and then select the next chapter. I want to put a button on the <code>listview</code> displaying all the lines (after the chapter has been selected) for the user to press and then it should basically re-query the db to display the next available chapter.</p>
  
  <p>Each <code>listview</code> is in it's own activity and id's gets passed with Intents.</p>
  
  <p>I don't know what code you guys want to see so please just ask.</p>
  
  <p>This is the <strong>list</strong> in <code>DBHandler2</code> for the chapters:</p>
  
  <pre><code>public List&lt;defineBybeldbAlles&gt; getListHoofstuk(String boek_id_na_hoofstuk){
          defineBybeldbAlles defineBybeldbHoofstuk = null;
          List&lt;defineBybeldbAlles&gt; defineBybeldbAllesList = new ArrayList&lt;&gt;();
          opendatabase();
          Cursor cursor = mDatabase.rawQuery("SELECT * FROM PWLBybel WHERE " + COLUMN_BOEK_ID + " = '" + boek_id_na_hoofstuk + "'GROUP BY hoofstuk_id ORDER BY hoofstuk_id * 1 ASC", null);
          cursor.moveToFirst();
          while (!cursor.isAfterLast()){
              defineBybeldbHoofstuk = new defineBybeldbAlles(cursor.getInt(0), cursor.getString(1),cursor.getString(2),cursor.getInt(3),cursor.getString(4),cursor.getInt(5),cursor.getString(6),cursor.getString(7),cursor.getInt(8),cursor.getString(9),cursor.getString(10));
              defineBybeldbAllesList.add(defineBybeldbHoofstuk);
              cursor.moveToNext();
          }
          cursor.close();
          closeDatabase();
          return defineBybeldbAllesList;
  }
  </code></pre>
  
  <p>This is <strong>where I pass</strong> the <code>chapter_id</code> <strong>in my chapter activity</strong> to diplay the lines in <strong>the lines activity</strong>:</p>
  
  <pre><code> public void onItemClick (AdapterView&lt;?&gt; arg0, View view, int arg2, long arg3){
  
                      //on selecting a hoofstk
                      //BybelActivityVers will be launched to show verse inside
                      Intent hoofstukIntent = new Intent(BybelActivityHoofstuk.this,BybelActivityVers.class);
  
                      //send hoofstuk_id to VersActivity to get verse under that book
                      String hoofstuk_id_na_vers = ((TextView)view.findViewById(R.id.hoofstuk_id)).getText().toString();
                      hoofstukIntent.putExtra("hoofstuk_id", hoofstuk_id_na_vers);
  
                      String hoofstuk_nommer_na_vers = ((TextView)view.findViewById(R.id.custom_row_hoofstuktext)).getText().toString();
                      hoofstukIntent.putExtra("custom_row_hoofstuktext", hoofstuk_nommer_na_vers);
  
                      startActivity(hoofstukIntent);
                  }
              });
  </code></pre>
  
  <p>Now this is the <strong>list</strong> in <code>DBHandler3</code> for the lines:</p>
  
  <pre><code>public List&lt;defineBybeldbAlles&gt; getListVers(String hoofstuk_id_na_vers){
          defineBybeldbAlles defineBybeldbVers = null;
          List&lt;defineBybeldbAlles&gt; defineBybeldbVersList = new ArrayList&lt;&gt;();
          opendatabase();
          Cursor cursor = mDatabase.rawQuery("SELECT * FROM PWLBybel WHERE " + COLUMN_HOOFSTUK_ID + " = '" + hoofstuk_id_na_vers + "'GROUP BY vers_id ORDER BY vers_id * 1 ASC", null);
          cursor.moveToFirst();
          while (!cursor.isAfterLast()){
              defineBybeldbVers = new defineBybeldbAlles(cursor.getInt(0), cursor.getString(1),cursor.getString(2),cursor.getInt(3),cursor.getString(4),cursor.getInt(5),cursor.getString(6),cursor.getString(7),cursor.getInt(8),cursor.getString(9),cursor.getString(10));
              defineBybeldbVersList.add(defineBybeldbVers);
              cursor.moveToNext();
          }
          cursor.close();
          closeDatabase();
          return defineBybeldbVersList;
  }
  </code></pre>