java - cursor.moveToFirst never returns true -
i'm trying search mediastore , far have had no luck in doing so.
here current code looks like:
cursor cursor = this.managedquery(uri, null, mediastore.audio.media.title + "=?", new string[]{songtoplay}, mediastore.audio.media.title + " asc"); if(cursor.movetofirst()){ do{ string path = cursor.getstring(cursor.getcolumnindex(mediastore.audio.media.data)); long id = cursor.getlong(cursor.getcolumnindex(mediastore.audio.media._id)); test.settext(path); } while (cursor.movetonext()); }
songtoplay, uri correctly set.
the if statement never executed.
what cause this?
it means the cursor empty. try out cursor.getcount()
, , double-check if query correct. sure media store populated? have permissions access it?
it looks building search functionality, way. if true, sure use operator, or better yet, use full text search.
Comments
Post a Comment