matrixcursor

When to use CursorJoiner / MatrixCursor / MergeCursor?

我怕爱的太早我们不能终老 提交于 2020-01-28 13:15:52
问题 I'm exploring different ways to get data elegantly from two or more joined tables. 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. 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

Difference between list and matrixcursor (Android)

非 Y 不嫁゛ 提交于 2020-01-15 12:11:20
问题 I'm trying to make a new android project in which I collect my data from an online JSON file. If I look on the internet, I can see a lot of examples where they are storing the collected data in a MatrixCursor. Personally, I think it's much easier (and much shorter/faster) to store all the data in a list in a model class. Is there a good reason why they are not using Lists instead of MatrixCursor, or what are the differences between them ? 回答1: I also prefer to have model classes that can be

Difference between list and matrixcursor (Android)

家住魔仙堡 提交于 2020-01-15 12:11:12
问题 I'm trying to make a new android project in which I collect my data from an online JSON file. If I look on the internet, I can see a lot of examples where they are storing the collected data in a MatrixCursor. Personally, I think it's much easier (and much shorter/faster) to store all the data in a list in a model class. Is there a good reason why they are not using Lists instead of MatrixCursor, or what are the differences between them ? 回答1: I also prefer to have model classes that can be

Passing binary blob through a content provider

对着背影说爱祢 提交于 2019-12-18 04:13:10
问题 I have a content provider that is custom to my set of Android applications, and one of the things it needs to expose is a small (20-30 KiB) byte array. The URI for these blobs looks like: content://my.authority/blob/# where # is the row number; the resulting cursor has the standard _id column and a data column. I'm using a MatrixCursor in the provider's query() method: byte[] byteData = getMyByteData(); MatrixCursor mc = new MatrixCursor(COLUMNS); mc.addRow(new Object[] { id, byteData });

Merging cursors during onLoadFinished() causes StaleDataException after rotation

白昼怎懂夜的黑 提交于 2019-12-07 13:30:49
问题 I'm loading some results from a database using a loaderManager. Unfortunately, the following code produces a StaleDataException after rotating the device: @Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { // If we've returned results, then pass them and the webSearches cursor along to be displayed if(cursor.moveToFirst()) { // Get a cursor containing additional web searches and merge it at the end of the results cursor MatrixCursor searchesCursor =

Merging cursors during onLoadFinished() causes StaleDataException after rotation

谁都会走 提交于 2019-12-05 22:52:38
I'm loading some results from a database using a loaderManager. Unfortunately, the following code produces a StaleDataException after rotating the device: @Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { // If we've returned results, then pass them and the webSearches cursor along to be displayed if(cursor.moveToFirst()) { // Get a cursor containing additional web searches and merge it at the end of the results cursor MatrixCursor searchesCursor = getWebSearchesCursor(searchTerm, false); Cursor[] cursors = { cursor, searchesCursor }; // TODO: Figure out why merging

When to use CursorJoiner / MatrixCursor / MergeCursor?

五迷三道 提交于 2019-11-29 19:52:11
I'm exploring different ways to get data elegantly from two or more joined tables. 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. 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

Using MatrixCursor and SimpleCursorAdapter in a ListView with text and images

て烟熏妆下的殇ゞ 提交于 2019-11-28 23:07:16
I'm having an issue using a MatrixCursor to populate my ListView : private void fillData() { String[] menuCols = new String[] { "icon", "item", "price" }; int[] to = new int[] { R.id.icon, R.id.item, R.id.price }; MatrixCursor menuCursor = new MatrixCursor(menuCols); startManagingCursor(menuCursor); menuCursor.addRow(new Object[] { R.drawable.chicken_sandwich, "Chicken Sandwich", "$3.99" }); SimpleCursorAdapter menuItems = new SimpleCursorAdapter( this, R.layout.menu_row, menuCursor, menuCols, to); setListAdapter(menuItems); } Constructing the SimpleCursorAdapter causes a crash. Even when I

Using MatrixCursor and SimpleCursorAdapter in a ListView with text and images

拈花ヽ惹草 提交于 2019-11-27 14:43:13
问题 I'm having an issue using a MatrixCursor to populate my ListView : private void fillData() { String[] menuCols = new String[] { "icon", "item", "price" }; int[] to = new int[] { R.id.icon, R.id.item, R.id.price }; MatrixCursor menuCursor = new MatrixCursor(menuCols); startManagingCursor(menuCursor); menuCursor.addRow(new Object[] { R.drawable.chicken_sandwich, "Chicken Sandwich", "$3.99" }); SimpleCursorAdapter menuItems = new SimpleCursorAdapter( this, R.layout.menu_row, menuCursor, menuCols