Udacity Android Learning Note: Lesson 4 Part B

Source: Internet
Author: User

Udacity Android Learning Note: Lesson 4 Part B

/titer1/archimedes of dry Goods shop chores
Source: Https://code.csdn.net/titer1
Contact: 13,073,161,968
Disclaimer: This document is licensed under the following agreement: Free reprint-Non-commercial-non-derivative-retention Attribution | Creative Commons by-nc-nd 3.0, reproduced please specify the author and source.
Tips:https://code.csdn.net/titer1/pat_aha/blob/master/markdown/android/

4b,后期将拆分为4大小节强烈建议保留自己重命名的字幕,又一次压制29units are waitted 上一章节完毕了 db的创建和内容的创建,这章节将讲到content provider,期待全部内容的大团结(汇总)
Why contents Providers Matter


How to understand the connection between multiple apps and a content provider

One create a content provider

More Todo

In-depth analysis of ContentProvider,
See Instructor Notes below
In the API SDK

1.1 What is URI

Data is assiated with views in the terms of universal resource identifiers or URIs.

一句话,universal resource identifiers简称
又见观察者模式theana content observer
1.2 Emphasis repeats how to build a content provider


-Determine URIs
-Update Contract
-Fill out URI Matcher
-Implement Fuctions

1.2.1 Define a URI


-Weather/location for Insert/update/delete
-Weather_with_location multi-day situation
-Weather_with_location_and_date Day situation

回想 contractitantheand views下一步将会讲到怎样 更新 contract
1.2.2 Update URI

4b-3 lesson todo? 为什么要绑定一串数字?一个URI相应一常数?最好的事就是这里加上调试的记录(动态)

This chapter is about the change of the Weathercontract class.
-Add Content_uri
-Add Content_Type

The careful person will find that the part is prepared for the initialization of the URI


This is where code tracking is needed, which forms the query.

Build URI

Here's checklist.

Look, notice the difference between this figure and the two graphs.
-Buildweatheruri was never realized.

1.2.3 Fill out Urimatcher

Urimatcher:
Uses a simple expression Ayntax to help us match URI ' s for a content provider

直觉,正則表達式


-#表示number
-* indicates string

Practice Time

Let's see what we do next.


Code like, that's it.

data,如今是基于数据库的data 构成uri
1.2.4 Content Provider1 2 4 1 Register the content provider
复习,什么是contact ?约定?进入到 test provider 的环节,

Lesson 4b_9 Now

1 2 4 2 content provider replace the SQL?

Register now, tell all (include Pakage Manager) by XML format

Here, the content resolver can resolve it!

Next to do:

Now, code time

1 2 4 3 Code the content Rovider OnCreate

Always think this is the last link, Contenprovider. Here, the oncreate of the mid-term

GetType is a function of content provider

As the gaze says, the function here is to test the use of UriBuilder.
And our mission is to add a response to weather_with_location_and_date and so on.

品读凝视,作用就在这里

Finally introduced here the original Testgetype, but will not finally use! So stare
See Todo list again

It's just a very quick answer.
We have added two URI types than the previous diagram

1 2 4 4 difficult code the Content Rovider query
刚刚把子标题标注好了,oh ,yeah!悄悄看了下prtplayeryeah!细心的点开 历史版本号记录,知道potplayer的开发历程,艰辛!


This is the more complex function of query, the legendary

Here is the bottom of the query function, which is important to say

    • Tell the Observer, they listen to the changes, happen to, and any of its descendants
setNotificationUri不止一处,待确认.

When all the query codes are added, we can open the gaze below and test our provider

Come on, it's another mission.

This is the time to complete all of the query, aha!

First Weahther Query code:

Then, location query code:

Initial comparison, feeling intuition first parameter, table name is different.

There are two tables, not operation, is the two separate tables, but need to inner join them
So

Meaning:
TBL INNER JOIN tbl2 on tbl.loc_key = tbl2.id

The following is selection, I think is to help memory

The following is a call to the Sqlbuilder query correlation function,
-Called the Sqlbuiler (call)
-Using the selection character function that was just encapsulated
-Number of references (location/startdate) from URI


The above only has location, the following will be the same time, including location and date query

The above two functions are called, Content provider query

能够为上面的三个函数图 绘制一个调用diagram其它:有没有在线 sql 数据库 语法 练习器online sql
Nap
    • Assuming a single-sheet query (just look at the weather or location), call it directly in the query function of the content provider
      SQL-related Qurey functions
    • Assuming that the two-sheet query is involved, it needs to be handled separately, and Sqlitequerybuilder is used here.

Query operation is complete, but the fourth Link has other operations, continue

Task Insert


The previous 2 minutes, the code is the above, just the details
-Exception handling
-insert URI-related trick (deep Todo when researching insert)


See also the task card, first in the goal is intact insert
”’
It is strongly recommended that you retain your own renamed captions, and again suppress
”’

Get ID for insert? Now

Tell Oberserver Now:

Test-driven development, such as the following, beautiful

Task Update + DELETE

4Inset 是一样的,取得 row courserr ,tell obersver... have a test所以要补图,或者补代码,后期补上,ok
Todo
    • Update Get Couser

    • Update FUN Tell Observer

    • Delete function Get Courser

    • Delete Functionj Tell Obersver

    • Call the test unit to ganrantee the work

Efficient Update & Insert
transaction10倍?

Repeat Summary content provider redux

理论上,我应该把经典的图再给站上来。、事实上应该把这里虽有字幕给摘抄出来,逐步分析。todo最后一句,“butitin our code ”,兴许将会用到实际项目里面
Todocreat Fetch Weahter Task
拍一个有羽毛的机器人吧重构

Udacity Android Learning Note: Lesson 4 Part B

Related Article

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.