managedQuery android方法的sql where子句

managedQuery android方法的sql where子句,android,database,image,where-clause,Android,Database,Image,Where Clause,我试图在android中将参数写入managedQuery方法,但在WHERE子句方面遇到了问题,以下是我编写的内容 Cursor imageCursor; // lots of other junk String[] proj = {MediaStore.Images.Media.TITLE}; imageCursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj, MediaStore.Images.

我试图在android中将参数写入managedQuery方法,但在WHERE子句方面遇到了问题,以下是我编写的内容

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 );
“filename”是保存图像路径的
字符串
变量,例如
/mnt/sdcard/pic05.png


我希望它返回一个游标,其中包含一条与pic05.png图像相同的记录,返回的游标将包含该特定图片的标题列信息。我是如何搞乱SQLWHERE子句的?我想我的语法一定是在where子句

中,在文件名周围添加“”。试试这个

   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 );

你是不是漏掉了几句话?(这些:)另外,您正在使用投影作为选择参数,这将不起作用,因为给定查询的当前形状,您不需要参数