开发者

Custom AbstractCursor with json content

开发者 https://www.devze.com 2023-03-19 08:53 出处:网络
Is it possible to us开发者_C百科e the cursor class to expose a json object? I have a custom abstract cursor(param = json object) and find I can\'t override the abstract cursor moveToFirst/moveToNext

Is it possible to us开发者_C百科e the cursor class to expose a json object? I have a custom abstract cursor(param = json object) and find I can't override the abstract cursor moveToFirst/moveToNext to support iteration. Any pointers on how to keep the json format(no probs parsing the json) within the cursor without transforming it, would be great.

Thanks Alex


You can use MatrixCursor to return data that you have either in xml or json format.

MatrixCursor : A mutable cursor implementation backed by an array of Objects.

final MatrixCursor cursor = new MatrixCursor(SEARCH_COLUMN_NAMES);              
for (OpenSearchHandler.Result result : results) {                       
     cursor.addRow(new Object[] { result.id, result.title, result.description, result.url });
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号