我读到ContentQueryMap可用于访问Cursor值,而不是每次都访问db。
但是,如何使用它? 官方的Android帮助是密封的......
答案 0 :(得分: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);
}