Java tutorial
//package com.java2s; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; public class Main { /** Returns true if there in the supplied database exists a row in the table 'tableName' where 'columnName'='columnValueWanted'. * * @param db A readable SQLiteDatabase object. * @param tableName The name of the table to scan. "FROM tableName" * @param columnName The name of the column * @param columnValueWanted The values you want to see if exists in a column. * @return Does the wanted value exist in the column in any row of the table in the database? */ public static boolean containsRowWithWhereStatement(SQLiteDatabase db, String tableName, String columnName, String columnValueWanted) { Cursor c = db.query(tableName, new String[] { columnName }, columnName + "=?", new String[] { columnValueWanted }, null, null, null, "1"); boolean output = c.getCount() > 0; c.close(); return output; } }