0

im trying to get the row id where the title equals the string i pass in.

Im pretty shakey on the syntax and i've been surfing around this site trying to find an example Eclipse will like. Usually it tells me that the arguments im providing are not valid but i cant seem to make sense of it. I've tried adding nulls to fill the other arguments like groupBy but it keeps telling me the arguments are wrong.

Heres my code

private String[] folderID = {MySQLiteHelper.COLUMN_FOLDERID};
private String[] folderTitle = {MySQLiteHelper.COLUMN_FOLDERNAME};


public Cursor findFolderId(String i){
String[] select = {i + "=" + folderTitle};
Cursor cursor = database.query(MySQLiteHelper.TABLE_FOLDERS, folderID, "WHERE", select);
return cursor;

EDIT:

Here is the typical error

The method query(String, String[], String, String[], String, String, String) in the type SQLiteDatabase is not applicable for the arguments (String, String[], String, String[])

2 Answers 2

1

You need change yours to:

String[] columns = {"Column1", "Column2"}; // columns to select
String selection = "someCol = ?";
String[] args = {i}; // value added into where clause --> column = i
Cursor c = database.query(TABLE, columns, selection, args, null, null, null);

Generally columns are columns you want to fetch, selection is equivalent to where clause, args are values which will be replaced instead of ?(this is called as placeholder) in same order.

Sign up to request clarification or add additional context in comments.

1 Comment

I think this is working, i cant tell yet due to other problems. Thanks for your help though.
0
public Cursor findFolderId(String i){
String[] select = {i};
Cursor cursor = database.query(MySQLiteHelper.TABLE_FOLDERS, folderID, folderTitle + "=?", select);
return cursor;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.