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 protocols: 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 repeated 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 follow-up code tracking is required, which forms the query.

Build URI

Here's checklist.

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

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 note says, the function here is to test the use of UriBuilder.
And our mission is to add a response such as weather_with_location_and_date.

品读注释,作用就在这里

The original Testgetype is finally introduced here, but will not be used in the end! So note
See Todo list again

But the answer is soon,
We have added two URI types than the previous figure

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 code is added, we can open the following comment 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.

With two tables, no action, two separate tables, but need inner join them
So

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

The following is selection, I think is to help the memory of

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


The above location only, the following will contain both location and date to query

The above two functions are called, Content provider query

可以为上面的三个函数图 绘制一个调用diagram其他:有没有在线 sql 数据库 语法 练习器online sql
Nap
    • If a single-sheet query (weather or location only) is called directly in the query function of the content provider
      SQL-related Qurey functions
    • If a query involving two tables is to be handled separately, the Sqlitequerybuilder is used here.

The query operation is complete, but there are other actions in the fourth session to continue

Task Insert


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


See also the task card, first in the goal is to perfect insert
”’
It is strongly recommended to retain your own renamed subtitles and re-suppress
”’

Get ID for insert? Now

Tell Oberserver Now:

Test-driven development, like the next, pretty

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倍?

Repeated summary of 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.