SQL WHERE子句managedQuery Android的方法 [英] sql where clause for managedQuery android method
问题描述
我试图写在Android和遇到问题的WHERE子句中的参数到managedQuery方法,这里是我写的;
I am trying to write the parameters to the managedQuery method in android and having trouble with the WHERE clause, here is what i wrote;
Cursor imageCursor;
// lots of other junk
String[] proj = {MediaStore.Images.Media.TITLE};
imageCursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj, MediaStore.Images.Media.DATA = filename, proj, null );
文件名是一个字符串
变量保存的图像,例如道路 /mnt/sdcard/pic05.png
"filename" is a string
variable holding the path of an image, example /mnt/sdcard/pic05.png
我希望它返回游标拿着一个记录是相同记录的pic05.png形象和返回将持有的TITLE列此信息,具体的画面光标。我怎么惹了SQL WHERE子句?我想,我的语法必须wroing在where子句
I want it to return a cursor holding a record that is the same record for the pic05.png image and the cursor returned would hold the TITLE column information for this specific picture. How did i mess up the sql WHERE CLAUSE? I thought that my syntax must be wroing on the where clause
推荐答案
添加周围的文件名。试试这个
Add ' ' around filename. Try this
Cursor imageCursor;
// lots of other junk
String[] proj = {MediaStore.Images.Media.TITLE};
String selection = MediaStore.Images.Media.DATA + "='" + filename +"'";
imageCursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj, selection, null, null );
这篇关于SQL WHERE子句managedQuery Android的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!