Content-Resolver自动生成“ WHERE”子句

时间:2019-07-18 06:57:53

标签: java android sqlite

我的应用在“ android.database.sqlite.SQLiteException”上崩溃

在“ where”子句中的SQL查询中,有一些我没有添加的代码,并且生成了)(storage_id = 65537)之间的错误,没有OR / AND:

(
  (mime_type IS NULL)
  OR (
    mime_type NOT IN(
      'application/vnd.oma.drm.message',
      'application/vnd.oma.drm.content',
      'application/vnd.oma.drm.dcf'
    )
  )
)(storage_id = 65537)

所以我有2个问题:

  1. 如何帮助系统生成没有错误的代码?
  2. 有什么办法可以看到ContentResolver创建的最终查询吗?

我以这种方式使用ContentResolver:

context.getContentResolver().query(uri, projection,
           selection, null,
           MediaStore.MediaColumns.DATE_ADDED);

错误代码:

Fatal Exception: android.database.sqlite.SQLiteException: near "(": 
syntax error (code 1): , while compiling:
SELECT arg1, arg2, arg3 FROM files WHERE ( ((mime_type IS NULL) OR 
(mime_type NOT 
IN('application/vnd.oma.drm.message',
'application/vnd.oma.drm.content',
'application/vnd.oma.drm.dcf')))(storage_id=656146433 OR 
storage_id=65537)) AND myWhere ORDER BY date_added

0 个答案:

没有答案