Android SQLite Query Not Working

I'm trying to search data on database based on 2 conditions (entryId=rowId & category=cat_id) like below

Cursor mCursor = db.query(true, "favorite", new String[] {"_id", "entry"}, "entryId="+ rowId + "& category="+cat_id, null, null, null, null, null);

Its not working. But when I try to do it using only one condition like below then it works well.

Cursor mCursor = db.query(true, "favorite", new String[] {"_id", "entry"}, "entryId="+ rowId, null, null, null, null, null);

Can you help me telling how can I run this query with multiple conditions?

Answers


In SQLite & is different from AND, simply use:

Cursor mCursor = db.query(true, "favorite", new String[] {"_id", "entry"}, 
        "entryId="+ rowId + " AND category="+cat_id, null, null, null, null, null);
// Change & to AND...  here:  ^^^

Need Your Help

How to send jQuery Autocomplete categories as part of the form submit?

javascript jquery autocomplete

I have jquery autocomplete with categories, when a person clicks on it with the mouse it gets send to a php page with that value and reports back a page. This works just fine.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.