Content Providers Flashcards

1
Q

What is content-provider for?

A

It’s created To give permission to multiple apps access the same data! It’s a middle things between the app and the data, also if you change the DB you wouldn’t have to change apps code!
From Android:
A content provider manages access to a central repository of data

Typically you work with content providers in one of two scenarios; you may want to implement code to access an existing content provider in another application, or you may want to create a new content provider in your application to share data with other applications

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

Where do we add the permission?

A

We add it in the Manifest file, before the application tag

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

how do we get permission to access another apps content provider?

A

&laquo_space;uses-permission android:name=”appdomain.TERMS_READ”/»

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

How do you get access to a content provider of another app? What is here in between us and the content provider to facilitate that?

A

By content resolver!

ContentResolver resolver = getContentResolver();

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

What can you do with the content resolver?

A

you can read, write, or update data from the content provider with it!

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

How can you read from a content resolver!

A

You get the content resolver to call the query function on it! It will return a cursor for you on the data.

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

What are the query method inputs?

A

mCursor = getContentResolver().query(
CONTENT_URI, // The content URI of the words table () mProjection, // The columns to return for each row
mSelectionClause, // Selection criteria
mSelectionArgs, // Selection criteria
mSortOrder);

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

Where should we get the CONTENT_URI?

A

From the documentation of the contract class that the application has

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

How do we access the contract class of the app we need the data from?

A

we should import the contract class form its provider

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

How can we understand that we are on the last row of the database on a cursor?

A

The .moveToNext() function will return false then

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