What I've done
I have a Gridview which is filled over my Database with the imageID's. Now I setted up a onItemClickListner with that I get the imageID -> this works!. Now I'd like to search my DB with that imageID, but it allways returns "null", but that shouldn't be because if filled my DB exactly with those imageID's. The Structure of the Table is that: RowID | SOURCE | INFO In Info i stored the imageID's
Question
How do I have to change Cursor that I can get the entries over INFO. Down here you find the Code of my Cursor:
Code:
//Es wird nach der ID des smiley gesucht.
public Cursor getSmiley(String info) throws SQLException {
Cursor mCursor =
this.mDb.query(true, DATABASE_TABLE, new String[] { INFO, SOURCE,
}, INFO + "=" + info, null, null, null, null, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
How I get the imageID-back
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(SFilterConfigActivity.this, "" + position, Toast.LENGTH_SHORT).show();
//Hier wird herrausgefunden welche ID das Bild hat und in den jeweiligen String gespeichert
source = String.valueOf(v.getId());
Log.v("IMAGEID", source);
SmileyHelper.open();
Cursor c = SmileyHelper.getSmiley(source);
startManagingCursor(c);
if (c != null){
String size = String.valueOf(c.getCount());
Log.v("WhatsInC", size);
}
if (c.moveToFirst()) {
do {
text = c.getString(c.getColumnIndex(SmileyDBAdapter.SOURCE));
Log.v("WHATINTEXT", text);
smiley = c.getString(c.getColumnIndex(SmileyDBAdapter.INFO));
Log.v("WHATINSMILEY", smiley);
} while (c.moveToNext());
SmileyHelper.close();
Additional Information:
- WhatIsInC, returns "0".
If you need more Code, just tell me Thx for your help in advance! Best Regards safari
The db.query has the following parameters:
So, in your query,
or