Building a content provider Flashcards
What is the first step in building a content provider?
create a class that extends it
What is the first step in building a content provider?
create a class that extends it
Who should have an instance of the DBhelper?
Dear COntent provider! Since it should have access to the Data
What is the second step? (Registering into?)
Manifest
How do we register a content provider to a Manifest?
provider tag, and name and authority and whether we wanna export it?
In what cases would I need a content provider?
- You want to offer complex data or files to other applications.
- You want to allow users to copy complex data from your app into other apps.
- You want to provide custom search suggestions using the search framework.
- You want to expose your application data to widgets.
- You want to implement the AbstractThreadedSyncAdapter, CursorAdapter, or CursorLoader classes.
Can a content provider save images? ofr files?
Yes, A content provider offers data in two ways:
File data
“Structured” data
What is a URI for content provider made of?
SCHEME+Authority+Path
What is the fourth step, it’s related to the contract class?
We need to add the defined URI s to the contract class!
Who should have an instance of the DBhelper?
Dear COntent provider! Since it should have access to the Data
In what cases would I need a content provider?
- You want to offer complex data or files to other applications.
- You want to allow users to copy complex data from your app into other apps.
- You want to provide custom search suggestions using the search framework.
- You want to expose your application data to widgets.
- You want to implement the AbstractThreadedSyncAdapter, CursorAdapter, or CursorLoader classes.
Can a content provider save images? ofr files?
Yes, A content provider offers data in two ways:
File data
“Structured” data
How do we append a path to a Uri? Let’s call our URI BASE_CONTENT_URI, and the path you wanna append PATH.
BASE_CONTENT_URI.buildUpon().appendPath(PATH_TASKS).build();
So you call BuildUpon and Build before and after Appending path which is wierd!
What is the fourth step, it’s related to the contract class?
We need to add the defined URI s to the contract class!
What is the UriMatcher for?
To make our code in the content provider cleaner! So that when the content provider should check the URIs to see where exactly should it to the operation, it doesn’t have to do it with if statements.