当使用CursorJoiner / MatrixCursor / MergeCursor?CursorJoiner、MatrixCursor、MergeCursor

2023-09-05 05:30:39 作者:今日来分享一组甜美又可爱的,这类的人气非常高,一起来看看有没

我在探索不同的方法来从两个或多个联接的表中获取数据优雅。

I'm exploring different ways to get data elegantly from two or more joined tables.

我相信 MergeCursor ,( Android开发者指南)似乎暗示,可能(例如)替换同等 SQL UNION 通过连接两个查询(或单独添加的意见,行等) - 所以,不我想要什么。

I believe MergeCursor, (Android Developer Guide) seems to imply that could (for example) replace an equivalent SQL UNION by concatenating two queries (or adding views individually as rows, etc) - so, not what I want.

但我无所适从,究竟 CursorJoiner MatrixCursor 是,或如何使用他们。我看了看源为他们(像往常一样),这对我毫无意义!我在使用中发现其中的例子并没有明确说明什么产生的效果。我真的AP preciate他们一个很好的说明,他们可能在使用的上下文。

But I'm at a loss as to what exactly CursorJoiner and MatrixCursor are for, or how to use them. I've looked at the source for them and (as usual) it means nothing to me! The examples I've found of them in use didn't clearly explain what the resulting effect was. I would really appreciate a good description of them, and the context they might be used in.

推荐答案

MergeCursor ,为您指示,目的是连接两个数据集垂直,增加更多的行

MergeCursor, as you indicate, is designed to concatenate two data sets "vertically", adding more rows.

CursorJoiner 的目的是连接两个数据集水平,增添更多的列。你可以认为这是类似于实现一个简单的 SQL JOIN

CursorJoiner is designed to concatenate two data sets "horizontally", adding more columns. You can think of this as akin to implementing a simple SQL JOIN.

MatrixCursor 允许你建立的东西,实现了光标界面出来的纯数据,你倒入二维数据模型

MatrixCursor allows you to build something that implements the Cursor interface out of pure data, that you pour into a two-dimensional data model.

AbstractCursor 允许您将自己的自定义数据的光标接口设置,覆盖是必要的方法

AbstractCursor allows you to wrap your own custom data set in a Cursor interface, overriding the methods that are necessary.