I am an android beginner. I’m trying to search whole database and find out if an “incoming” number is in a database or not and if it does exist return true if not return false,
My code for searching is included below, however it always return true even if I call it with a number that doesn’t exist in the database.
In addition Should I use LIKE for searching because sometimes the incoming number is within the code of city for example *0060*172214866 or 0172214866, .(type of incomingnumber is String )
thanks in advance and sorry for any poor use of English
public boolean searchnumber(String incomiingnumber) {
boolean isit = false;
Cursor c=ourdatabase.query(DATABASE_TABLE, new String[]
{ROW_ID,KEY_NUMBER,N_NAME},
KEY_NUMBER + "=" + incomiingnumber
,null,null,null,null );
if (c != null){
while(c.moveToNext())
isit= true; }
else
{
isit=false;
Log.v(incomiingnumber, "IS NOT it");
}
return isit;
}
I suggest using like, then using the minimum sequence you need to compare.
Try this: