title: How to query android sqlite database and store results in a string that can be displayed in a webview?
body: <p>I've read tons of articles and books on the subject. For the most part a have a decent grasp of android development. But I'm having a hard time incorporating a database. I have a database called "Library". In the database I have a table called "Books". And in the "Books" table I have 3 columns "id, Book, Chapter". I want to reference the Chapter field based off of the Book field for example..."Select Chapter FROM Books WHERE Book ="Genesis1";. The Contents of the Chapter field is pure html so I would like to save the output of my query to a string and then put that string into a webview, the purpose being so that I can create a search a search box or widget to enable the user to search all book content. Here's what I have so far:</p>
  
  <p>Constants.java</p>
  
  <pre><code>package watchtower.library.org;
  
  import android.provider.BaseColumns;
  
  public interface Constants extends BaseColumns {
  public static final String TABLE_NAME = "Books";
  
  public static final String Book = "book";
  public static final String Chapter = "chapter";
  }
  </code></pre>
  
  <p>LibraryData.java</p>
  
  <pre><code>package watchtower.library.org;
  
  import static android.provider.BaseColumns._ID;
  import static watchtower.library.org.Constants.TABLE_NAME;
  import static watchtower.library.org.Constants.Book;
  import static watchtower.library.org.Constants.Chapter;
  import android.content.Context;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  
  public class LibraryData extends SQLiteOpenHelper {
  private static final String DATABASE_NAME = "WatchtowerLibrary.db";
  private static final int DATABASE_VERSION = 1;
  
  public LibraryData(Context ctx){
      super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
  }
  @Override
  public void onCreate(SQLiteDatabase db) {
      db.execSQL("CREATE TABLE " + TABLE_NAME +"( +_ID" 
              + " INTEGER PRIMARY KEY AUTOINCREMENT, " + Book
              + " INTEGER," + Chapter + " TEXT NOT NULL);");
  
  }
  @Override
  public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
      // TODO Auto-generated method stub
  
  }
  }
  </code></pre>
  
  <p>Genesis1.java</p>
  
  <pre><code>package watchtower.library.org;
  
  import static watchtower.library.org.Constants.TABLE_NAME;
  import static watchtower.library.org.Constants.Chapter;
  import android.app.Activity;
  import android.content.ContentValues;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.os.Bundle;
  import android.webkit.WebChromeClient;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  
  public class Genesis1 extends Activity {
  private LibraryData WatchtowerLibrary;
  private Cursor getEvents() {
      SQLiteDatabase db = WatchtowerLibrary.getReadableDatabase();
      Cursor cursor = db.rawQuery("SELECT Chapter" + "FROM" + TABLE_NAME + "WHERE                                                                                                              
  Book is Genesis1", null); 
      startManagingCursor(cursor);
      return cursor;
  }
  private WebView webView;
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.scriptures);
  
      webView = (WebView) findViewById(R.id.webview);
      webView.getSettings().setJavaScriptEnabled(true);
      webView.setWebViewClient(new WebViewClient());
      webView.setWebChromeClient(new WebChromeClient());   
  }
  }
  </code></pre>
  
  <p>And that's where I'm stuck!! lol! I'm probably way off track. I'm greatfull for whatever suggestions you might have. Thanks!</p>