Add the contents of one cursor to another cursor

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

This is where my code is,

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); 

Should I use CursorJoiner in this case?

I want to pass this cursor to SimpleListAdapter? How can I join these two cursors?

Thanks!!

+4
source share
2 answers

well, I solved it myself and worked, decrypting AbstractCursor, heres 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]; } 
+2
source

Perhaps you can use the MergeCursor wrapper to combine your two cursors into a new one and pass them to your adapter.

+16
source

Source: https://habr.com/ru/post/1334165/


All Articles