I read that ContentQueryMap can be used to access Cursor values not to access the db everytime.
我读到ContentQueryMap可以用来访问游标值,而不是每次都访问db。
But, how to use it? The Official Android help is hermetic...
但是,如何使用它呢?官方的Android帮助是密封的…
1 个解决方案
#1
0
ContentQueryMap mQueryMap = new ContentQueryMap(cursor, BaseColumns._ID, true, null);
Comparator<Long> numberAmaxB = new Comparator<Long>() {
@Override public int compare(Long s1, Long s2) {
if (s1<s2)
return 1;
else if (s1>s2)
return -1;
else
return 0;
}
};
SortedMap<Long, String> mySortedMap = new TreeMap<Long, String>(numberAmaxB);
for (Map.Entry<String, ContentValues> row : mQueryMap.getRows().entrySet()) {
Long _ID = Long.valueOf(row.getKey());
String data= row.getValue().getAsString("data_column");
conversationsSortedMap.put(_ID, data);
}
#1
0
ContentQueryMap mQueryMap = new ContentQueryMap(cursor, BaseColumns._ID, true, null);
Comparator<Long> numberAmaxB = new Comparator<Long>() {
@Override public int compare(Long s1, Long s2) {
if (s1<s2)
return 1;
else if (s1>s2)
return -1;
else
return 0;
}
};
SortedMap<Long, String> mySortedMap = new TreeMap<Long, String>(numberAmaxB);
for (Map.Entry<String, ContentValues> row : mQueryMap.getRows().entrySet()) {
Long _ID = Long.valueOf(row.getKey());
String data= row.getValue().getAsString("data_column");
conversationsSortedMap.put(_ID, data);
}