ContentProvider provides custom data structures

Source: Internet
Author: User

ContentProvider we've implemented a couple of these methods, which we all know. But the cursor returned by the query method is implemented by itself and then the data structure that needs to be passed in to the cursor in its own writing is incorrect. Sometimes it might feel like it can Testing is not possible because the cursor is pointing to a collection of underlying data that cannot carry data or that should not carry data
Cursor is initialized when the pointer points to the data collection where the position is-1 this will always be thrown without this value.

The document says that when the cursor should be implemented instantiate a matrixcursor it's actually a table of our own custom.
string[] columns = new string[] {"_id", "_value"};
Matrixcursor cursor = new matrixcursor (columns);

This is the table of our own established table the first column is the ID the second column is value

This gives you a table instead of a database or a cursor interface.

string[] STRs = new string[]{"0", "a"};
Cursor.addrow (STRs);

So we've written id=0 value=a for the table.

When we use the Contentresolver query method, the cursor will be passed right back without any exceptions inside the cursor wrapper.

ContentProvider provides custom data structures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.