private static List<Result> queryRecentLocations(ContentResolver resolver,String input,Context context){
  String filter=input == null ? "" : input + "%";
  if (filter.isEmpty()) {
    return null;
  }
  if (Build.VERSION.SDK_INT >= 23 && ContextCompat.checkSelfPermission(context,Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
    Log.d(TAG,"Manifest.permission.READ_CALENDAR is not granted");
    return null;
  }
  Cursor c=resolver.query(Events.CONTENT_URI,EVENT_PROJECTION,LOCATION_WHERE,new String[]{"1",filter},Events._ID + " DESC");
  try {
    List<Result> recentLocations=null;
    if (c != null) {
      recentLocations=processLocationsQueryResults(c);
    }
    return recentLocations;
  }
  finally {
    if (c != null) {
      c.close();
    }
  }
}

private static List < Result > queryRecentLocations ( ContentResolver resolver , String input , Context context ) { String filter = input == null ? "" : input + "%" ; if ( filter . isEmpty ( ) ) { return null ; } if ( Build . VERSION . SDK_INT >= 23 && ContextCompat . checkSelfPermission ( context , Manifest . permission . READ_CALENDAR ) != PackageManager . PERMISSION_GRANTED ) { Log . d ( TAG , "Manifest.permission.READ_CALENDAR is not granted" ) ; return null ; } Cursor c = resolver . query ( Events . CONTENT_URI , EVENT_PROJECTION , LOCATION_WHERE , new String [ ] { "1" , filter } , Events . _ID + " DESC" ) ; try { List < Result > recentLocations = null ; if ( c != null ) { recentLocations = processLocationsQueryResults ( c ) ; } return recentLocations ; } finally { if ( c != null ) { c . close ( ) ; } } }
matches the input string against recent locations .
