一个光标的内容添加到另一个光标 [英] Add the contents of one Cursor to another Cursor

查看:116
本文介绍了一个光标的内容添加到另一个光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要加入两个光标,使第二光标的内容也应加入后出现在第一光标。

I want to join two cursors so that the contents of the second Cursor shall also appear in first Cursor after joining.

precisely这里是我的code,

Precisely here is my code,

public final Uri AllImage_URI_Int = MediaStore.Images.Media.INTERNAL_CONTENT_URI;
public final Uri AllAudio_URI = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
cContentList = managedQuery(AllImage_URI_Int, null, null, null, MediaStore.Images.ImageColumns.TITLE);
cList_Int = managedQuery(AllImage_URI, null, null, null, MediaStore.Images.ImageColumns.TITLE);

我应该使用 CursorJoiner 在这种情况下, ?

Should i use the CursorJoiner in this case?

我想通过这个光标到SimpleListAdapter?我如何加入这两个游标?

I want to pass this Cursor to SimpleListAdapter? How can i join those two cursors?

谢谢!

推荐答案

嗯,我解决了它自己和工作,extendeb由AbstractCursor,继承人的code,

well, i solved it myself and working, extendeb by AbstractCursor, heres the code,

private final int ROWCACHESIZE = 64;
private int mRowNumCache[] = new int[ROWCACHESIZE];
private int mCursorCache[] = new int[ROWCACHESIZE];
private int mCurRowNumCache[][];
private int mLastCacheHit = -1;

public SortCursor(Cursor[] cursors, String sortcolumn)
{
    mCursors = cursors;

    int length = mCursors.length;
    mSortColumns = new int[length];
    for (int i = 0 ; i < length ; i++) {
        if (mCursors[i] == null) continue;

        mCursors[i].moveToFirst();

        // We don't catch the exception
        mSortColumns[i] = mCursors[i].getColumnIndexOrThrow(sortcolumn);
    }
    mCursor = null;
    String smallest = "";
    for (int j = 0 ; j < length; j++) {
        if (mCursors[j] == null || mCursors[j].isAfterLast())
            continue;
        String current = mCursors[j].getString(mSortColumns[j]);
        if (mCursor == null || current.compareToIgnoreCase(smallest) < 0) {
            smallest = current;
            mCursor = mCursors[j];
        }
    }

    for (int i = mRowNumCache.length - 1; i >= 0; i--) {
        mRowNumCache[i] = -2;
    }
    mCurRowNumCache = new int[ROWCACHESIZE][length];
}

这篇关于一个光标的内容添加到另一个光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆