Content Provider: General Overview Flashcards

1
Q

What is a Content Provider?

A

A Content Provider is an abstraction layer that manages interactions to a specific data source on the application. For example, calendar, phone contacts, reminders etc.
Each data source has a designated Content Provider to manage queries from system wide applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the Content Resolver?

A

A system mechanism which manages and moderates queries to data sources in such a way as to prevent query clashes that may cause data inconsistency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In what 2 scenarios is a content provider used?

A
  • Implement code to access the content provider of another application.
  • Implement a content provider in your own application to share data with other applications.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does android:exported = ‘true’ do?

A

It ensures that other applications can access your applications content provider.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

If app A wants to write and read to app B’s content provider, what does app A list in their manifest?

A

android:name = “com.example.destContentProvider.PERMISSION”. This enables your application to use the mentioned Content Provider.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why do we query the content provider off the UI thread?

A

To avoid idle processing time when waiting for querying operations to finish. Otherwise, we could receive an ANR error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What class do we used to query the Content provider? What generics does it take?

A

AsyncTask<Params, Progress, Result>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the 3 methods of AsyncTask? What do they do?

A

onPreExecute() -> In UI thread to set up hand-off.
doInBackground(Params) -> Execute the code, returns a cursor object referencing the subsection of the data source.
onPostExecute(Result) -> Generally pass the cursor as argument. Can then use cursor to operate on data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly