How to filter the results of content resolver in android?

前端 未结 4 1439
再見小時候
再見小時候 2020-12-07 20:37

I would like to get user contacts and then append some kind of regular expression and append them to a list view. I am currently able to get all the contacts via

4条回答
  •  猫巷女王i
    2020-12-07 21:39

    Actually REGEXP with Calllog Content Provider works (means that regexp() function is defined for that content provider's Database https://sqlite.org/lang_expr.html#regexp)! But it is very slow: ~15 sec across ~1750 records.

    String regexp = "([\\s\\S]{0,}" + 
    TextUtils.join("||[\\s\\S]{0,}", numbers) + 
    ")";
    
    cursor = context.getContentResolver().query(
    CallLog.Calls.CONTENT_URI, 
    null, 
    CallLog.Calls.NUMBER + " REGEXP ?", 
    new String[]{regexp}, 
    CallLog.Calls.DATE + " DESC"
    );
    

提交回复
热议问题