/** * Execute a raw SQLite query. This method takes an Object[] for the arguments because Android's default behavior * of binding all arguments as strings can have unexpected bugs, particularly when working with functions. For * example: * * <pre> * select * from t where _id = '1'; // Returns the first row * select * from t where abs(_id) = '1'; // Always returns empty set * </pre> * * To eliminate this class of bugs, we bind all arguments as their native types, not as strings. Any object in the * array that is not a basic type (Number, String, Boolean, etc.) will be converted to a sanitized string before * binding. * * @param sql a sql statement * @param sqlArgs arguments to bind to the sql statement * @return a {@link ICursor} containing results of the query */ public ICursor rawQuery(String sql, Object[] sqlArgs) { acquireNonExclusiveLock(); try { return getDatabase().rawQuery(sql, sqlArgs); } finally { releaseNonExclusiveLock(); } }
/** * Execute a raw SQLite query. This method takes an Object[] for the arguments because Android's default behavior * of binding all arguments as strings can have unexpected bugs, particularly when working with functions. For * example: * * <pre> * select * from t where _id = '1'; // Returns the first row * select * from t where abs(_id) = '1'; // Always returns empty set * </pre> * * To eliminate this class of bugs, we bind all arguments as their native types, not as strings. Any object in the * array that is not a basic type (Number, String, Boolean, etc.) will be converted to a sanitized string before * binding. * * @param sql a sql statement * @param sqlArgs arguments to bind to the sql statement * @return a {@link ICursor} containing results of the query */ public ICursor rawQuery(String sql, Object[] sqlArgs) { acquireNonExclusiveLock(); try { return getDatabase().rawQuery(sql, sqlArgs); } finally { releaseNonExclusiveLock(); } }