[Development Diary of Android in a row from scratch] (9) -- ContentProvider of four Android components and four android Components

Source: Internet
Author: User

[Development Diary of Android in a row from scratch] (9) -- ContentProvider of four Android components and four android Components
Different from other components, the data source component ContentProvider does not include specific functional logic. It is only responsible for providing data access interfaces for applications. Many of the data built in Android is in the ContentProvider format for developers to call (such as video, audio, image, Address Book, etc ). If a third-party application is compared to a black box, ContentProvider is like an extension pipe from the inside. From this pipe, the application can share some data, and we can also deliver data to it. However, we cannot see or manage how to process the data. In addition, this pipeline has standard standards, and you cannot plug in the data specified by it.

 

1. Features of ContentProvider

2. ContentProvider instance

Let's get to know it through an instance. Use ContentProvider to operate a third-party database.

3. Call ContentProvider

When using the ContentProvider provided by other applications for you, you must know two points: (1) its authorities value, here I am "com. example. database "; (2) Structure of the data file. For example, I want to use the booknote table in the database, which contains the fields (_ id, title, content, time. Only by knowing this can you operate ContentProvider.

Iv. Conclusion

Theoretically, the data source component does not have a so-called life cycle, because the status of the data source component is not used as a basis for determining the priority of the process. Therefore, when the system recycles process resources, it does not notify developers of the destruction events of data source components. However, when constructing the ContentProvider component, the onCreate () function is still called. Therefore, do not deploy write optimization policies such as delayed writing in the data source components. When the system silently recycles data, some non-persistent data will be lost. Once the data source component is constructed, it will remain in the Long-term Running State until the process where it is located is recycled by the system. Therefore, do not cache too much data in the data source component to avoid occupying the memory space.

 

At this point, the four components of Android have been introduced, each of which has its own characteristics and usage, and is also an indispensable tool for our development. We hope that these introductions will help you understand the clever design and features of Android and learn how to correctly use the Android Application Framework. Next, we may bring about the Android Intent mechanism ~

 

Reference: (1) ContentProvider and Uri detailed http://www.cnblogs.com/linjiqin/archive/2011/05/28/2061396.html

(2)ContentProvider analysis http://bbs.51cto.com/thread-1024108-1.html

(3) learning from scratch Android ContentProvider http://blog.csdn.net/worker90/article/details/7016430

Download: demo download

==========================================================

Author: cpacm

Source:Http://www.cnblogs.com/cpacm/p/3929274.html)

 




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.