Android : Regex in SQLite query gives unrecognized token exception

on Tuesday, September 30, 2014


I have the following query:



String selectQuery = "SELECT * FROM " + DOCUMENT_TABLE + " WHERE " + DOCUMENT_TYPE + " REGEXP " + "(^|,)(pdf)(,|$)";


At compile time I receive this error:



android.database.sqlite.SQLiteException: unrecognized token: "^" (code 1): , while compiling: SELECT * FROM DOCUMENTTABLE WHERE TYPE REGEXP (^|,)(pdf)(,|$)



The column from where clause has values written in the following format:



  • doc,pdf

  • pdf

  • pdf,doc


How to use regex to retrieve the right information (my case, get all documents that are in pdf format, too)?


0 comments:

Post a Comment