1

What am I doing wrong!?!?? I am trying to get a set of data to a listview.

First I Open the database and then I trying to get the set, I get a response but only 1 row from the database and I am getting at least 10 when I trying it in sqlite browser..... Anyway I don't know if this make any sense, here is the code: (i am new at this, please don't laugh to much)

And btw I use the same methods/functions in another listview but then I don't have any WHERE in my query and that works fine.... So I want to get all the rows from the database and i only get the first one :)

Thanks mates!

db.openDataBase();
Cursor c = db.getCoursesFromCountyID(countyID);
BindsimpleCursorAdapter(c);
db.close();

the getCoursesFromCountyID = 
int id = Integer.parseInt(county);
        return db.query("Courses", new String[]{KEY_course_ID, KEY_course}, KEY_county_ID + " = " + id, null, null, null, null);

And the BindsimpleCursorAdapter looks like this = 

startManagingCursor(c);
        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.simpleadapter_courses, c, new String[]{DataBaseHelper.KEY_course_ID, DataBaseHelper.KEY_course}, new int[]{R.id.courseID, R.id.course});
        ListView lv = new ListView(this);
        lv = (ListView)findViewById(R.id.listViewCourses);
        lv.setAdapter(adapter);

1 Answer 1

1

I don't see any problems on your code, try adding 'KEY_county_ID' to you projection argument and removing the selection argument to check if all the rows are really there.

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

1 Comment

So i have tried with no where, and i got all the data... so I tried to write the colum name instead of having it as a key. And it WORKS!!! The only thing I edit was: THIS return db.query("Courses", new String[]{KEY_course_ID, KEY_course}, KEY_county_ID + " = " + id, null, null, null, null); TO THIS return db.query("Courses", new String[]{KEY_course_ID, KEY_course}, "countyID = " + id, null, null, null, null); Thanks man!!!! AWESOME!

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.