Use selectionArgs parameter to pass mCurquery.

This commit is contained in:
Miroojin Bakshi 2014-03-06 16:27:35 +05:30
parent 7932dd8a81
commit fab549c2b5
2 changed files with 12 additions and 8 deletions

View File

@ -239,12 +239,14 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
// sample only has one Loader, so we don't care about the ID.
Uri baseUri = KeyRings.buildPublicKeyRingsUri();
String where = null;
if(mCurQuery != null)
where = KeychainContract.UserIds.USER_ID + " LIKE \"" + mCurQuery + "%\"";
String whereArgs[] = null;
if(mCurQuery != null){
where = KeychainContract.UserIds.USER_ID + " LIKE ?";
whereArgs = new String[]{mCurQuery+"%"};
}
// Now create and return a CursorLoader that will take care of
// creating a Cursor for the data being displayed.
return new CursorLoader(getActivity(), baseUri, PROJECTION, where, null, SORT_ORDER);
return new CursorLoader(getActivity(), baseUri, PROJECTION, where, whereArgs, SORT_ORDER);
}
@Override

View File

@ -226,13 +226,15 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
orderBy = inMasterKeyList + " DESC, " + orderBy;
}
String where = null;
if(mCurQuery != null)
where = UserIds.USER_ID + " LIKE \"" + mCurQuery + "%\"";
String whereArgs[] = null;
if(mCurQuery != null){
where = UserIds.USER_ID + " LIKE ?";
whereArgs = new String[]{mCurQuery+"%"};
}
// Now create and return a CursorLoader that will take care of
// creating a Cursor for the data being displayed.
return new CursorLoader(getActivity(), baseUri, projection, where, null, orderBy);
return new CursorLoader(getActivity(), baseUri, projection, where, whereArgs, orderBy);
}
@Override