How to use SQL to search for a value?
<p>I'm trying to learn how to use database in Android and so far I have learned how to fetch all rows of data in the table, but I'm not sure how I'm going to use a SQL query to search for a value that is equal to the string value I pass to the method below?</p>

<p>I wonder if someone could add some simple code how to query the database with SQL in my code? Preciate the help! Thanks! </p>

<p>Something like this: <code>String query = "Select * from DB_TABLE where TABLE_IMAGE_PATH = filePath";</code></p>

<pre><code>// Read from database
public String readContacts(String filePath){

    String[] columns = new String[]{TABLE_ID, TABLE_IMAGE_PATH, TABLE_CONTACT_NAME, TABLE_CONTACT_NUMBER, TABLE_CONTACT_ADDRESS};
    Cursor c = db.query(DB_TABLE, columns, null, null, null, null, null);

    int id = c.getColumnIndex(TABLE_ID);
    int imagePath = c.getColumnIndex(TABLE_IMAGE_PATH);
    int name = c.getColumnIndex(TABLE_CONTACT_NAME);
    int number = c.getColumnIndex(TABLE_CONTACT_NUMBER);
    int address = c.getColumnIndex(TABLE_CONTACT_ADDRESS);

    String result = "";

    for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){ 
    result = result + c.getString(id) + " " + c.getString(imagePath) + " " + c.getString(name) + " " + c.getString(number) + " " + c.getString(address);
    }

    return result;
}
</code></pre>
