mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
Fixing query so that it uses wildcards
This commit is contained in:
parent
a427b8cead
commit
2098436a2c
File diff suppressed because it is too large
Load Diff
@ -24,6 +24,7 @@ import org.json.JSONObject;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.database.Cursor;
|
||||
import android.provider.ContactsContract;
|
||||
import android.provider.Contacts.ContactMethods;
|
||||
import android.provider.Contacts.ContactMethodsColumns;
|
||||
import android.provider.Contacts.Organizations;
|
||||
@ -61,7 +62,12 @@ public class ContactAccessorSdk3_4 extends ContactAccessor {
|
||||
boolean multiple = true;
|
||||
try {
|
||||
searchTerm = options.getString("filter");
|
||||
if (searchTerm.length()==0) searchTerm = "%";
|
||||
if (searchTerm.length()==0) {
|
||||
searchTerm = "%";
|
||||
}
|
||||
else {
|
||||
searchTerm = "%" + searchTerm + "%";
|
||||
}
|
||||
multiple = options.getBoolean("multiple");
|
||||
if (multiple) {
|
||||
limit = options.getInt("limit");
|
||||
@ -75,9 +81,15 @@ public class ContactAccessorSdk3_4 extends ContactAccessor {
|
||||
JSONObject contact;
|
||||
|
||||
ContentResolver cr = mApp.getContentResolver();
|
||||
Cursor cur = cr.query(People.CONTENT_URI,
|
||||
null, null, null, null);
|
||||
|
||||
// Right now we are just querying the displayName
|
||||
Cursor cur = cr.query(People.CONTENT_URI,
|
||||
null,
|
||||
People.DISPLAY_NAME + " LIKE ?",
|
||||
new String[] {searchTerm},
|
||||
People.DISPLAY_NAME + " ASC");
|
||||
|
||||
|
||||
int pos = 0;
|
||||
while (cur.moveToNext() && pos < limit) {
|
||||
contact = new JSONObject();
|
||||
|
@ -63,19 +63,23 @@ public class ContactAccessorSdk5 extends ContactAccessor {
|
||||
boolean multiple = true;
|
||||
try {
|
||||
searchTerm = options.getString("filter");
|
||||
if (searchTerm.length()==0) searchTerm = "%";
|
||||
if (searchTerm.length()==0) {
|
||||
searchTerm = "%";
|
||||
}
|
||||
else {
|
||||
searchTerm = "%" + searchTerm + "%";
|
||||
}
|
||||
multiple = options.getBoolean("multiple");
|
||||
if (multiple) {
|
||||
limit = options.getInt("limit");
|
||||
}
|
||||
|
||||
System.out.println("Limit = " + limit);
|
||||
System.out.println("Multiple = " + multiple);
|
||||
} catch (JSONException e) {
|
||||
Log.e(LOG_TAG, e.getMessage(), e);
|
||||
}
|
||||
// Get a cursor by creating the query.
|
||||
ContentResolver cr = mApp.getContentResolver();
|
||||
|
||||
// Right now we are just querying the displayName
|
||||
Cursor cursor = cr.query(
|
||||
ContactsContract.Contacts.CONTENT_URI,
|
||||
new String[] {ContactsContract.Contacts._ID, ContactsContract.Contacts.HAS_PHONE_NUMBER, ContactsContract.Contacts.DISPLAY_NAME},
|
||||
|
Loading…
Reference in New Issue
Block a user