Is particular bookmark a content provider? - android

I know that browser is content provider but i want to know, is bookmark (which support to browser) is also a content provider.

Be aware in android 6 global bookmarks are removed.
In general, any app can implement its own bookmarks and share it as content provider.
You may ask - but how do clients find provider? Well, it’s required to know the URIs of a provider to access it. The recommendation is to publish public constants for the URIs and document them to other developers.

Related

Is it possible for my own document provider to be offered only within my app?

This is a very short answer, which I couldn't find an answer to, not in in the docs and not anywhere over the Internet:
On Android, apps can offer the user to choose files from them, to be chosen from other apps. For example, the Google Photos app allows to choose photos files from it. This is done by implementing DocumentProvider .
I'd like to ask if it's possible to offer my app's content, only to my app itself.
This can help in the case of providing photos selection, for example, that is relevant only for the app itself.
From this docs link:
Create a custom document provider
"The attribute android:exported set to "true". You must export your provider so that other apps can see it."
Set android:exported to false inside your manifest.
The DocumentProvider is a ContentProvider so looking at the documentation for ContentProvider will supply a lot more info:
ContentProvider
"false: The provider is not available to other applications. Set android:exported="false" to limit access to the provider to your applications. Only applications that have the same user ID (UID) as the provider will have access to it."

Android: Why doesn't the UserDictionary.Words extend the ContentProvider class?

From the developer guide of Content Providers:
Android itself includes content providers that manage data such as
audio, video, images, and personal contact information.
From the developer guide of Content Provider Basics:
one of the built-in providers in the Android platform is the user
dictionary, which stores the spellings of non-standard words that the
user wants to keep.
From the Javadoc of ContentProvider:
Known Direct Subclasses DocumentsProvider, FileProvider,
MockContentProvider, SearchRecentSuggestionsProvider
From the API documentation of UserDictionary.Words:-
java.lang.Object
↳ android.provider.UserDictionary.Words
They are saying that Android Platform comes with some built-in content providers. Then say that Android platform has a built-in provider user dictionary. Secondly, if we implement our own content provider, even then we subclass ContentProvider class, right?
So why doesn't UserDictionary.Words content provider extent the ContentProvider class?

android content provider AUTHORITIES

What is the reason for content provider authorities?
How/why do I want to use them other than I HAVE to declare them in the manifest?
I've tried to do my homework on this question and cannot find a decent, cohesive discussion on this topic.
Here is the best I could find (in additi on to the four books on Android development I own):
https://stackoverflow.com/search?q=content+provider+authority
Content Providers, Authority and and URI matching
Get a list of available Content Providers
http://developer.android.com/guide/topics/manifest/provider-element.html
http://developer.android.com/guide/topics/providers/content-provider-creating.html
The Authority is used to interact with a particular content provider, that means it must be unique. That's why is a good practice to declare it as your domain name (in reverse) plus the name of the package containing the provider, that way is less likely that other developer creates an app with a content provider declaring the same authority.
You declare it in the manifest so your app and other apps (if you let them) can manipulate
data through your content provider in the form of a uri:
content://authority-name/data-in-the-provider
It works similar to domains in http urls:
http://domain-name/data-in-the-site
I am also looking for explanation and to add to answer provided by ILovemyPoncho, I hit this particular answer and I quote:
and what exactly is android:authorities asking for?
A system wide unique identifier for your provider. Or better worldwide
unique. All providers are registered with the system and they need to
be unique or the second app that wants to use the same name can't be
installed.
You use that string in the end to communicate with your provider via
an Uri like
Uri uri = Uri.parse("content://" + "your.authoritiy.string")
Let's put it this way: There is an invisible hand that facilitates your request to your app's ContentProvider.
For example:
Uri uri = mContext.getContentResolver().insert(NotifireContentProvider2.NOTE_URI, values);
Basically, what you are saying here to the Android OS is insert data given the URI containing the authority you have defined in the XML. The OS will search for this particular content provider and send the request to it. You insert method on the ContentProvider will be called and you must match the URI to handle it accordingly.
Also, what if, you're content provider is so simplistic that others have similar authority as well. I haven't encountered those two problem I mentioned but I reckon it won't be pleasant.
Authority is there to make sure that the OS understand which provider will provide the data to the requesting app and to make sure that is the provider providing it.

How many content provider we can implement in one app?

I've read Android dev guide and notice that we can implement different classes for the content provider. So,
There are many content providers or just one content provider in one Android app?
How to properly implement different content provider classes like that?
Here is what I read from the dev guide:
You implement a provider as one or more classes in an Android
application
http://developer.android.com/guide/topics/providers/content-provider-creating.html
You can implement as many as you want, as you can see from the documentation here. To register a content provider, you need to add its corresponding <provider> tag in the Android Manifest.
In most cases, however, you won't need multiple content providers. One is usually enough, as it can handle multiple tables. You should only really need more than one if you want your app to provide public access to 2+ separate data entities.
You can use (provide as well as use) as many content providers per app as you need. They need different content URIs, of course.
In addition to the uses outlined in the document (your link) you can use content providers for other purposes as accessing data storage. The content URI can have parameters, so you can use a content provider similarly to a web service.
You can create as many content providers as you want. But do you need them al?
What content provider classes do you want to implement? If you read the page very good you should have seen that it contains links to two pages:
http://developer.android.com/guide/topics/providers/content-provider-basics.html - Content Provider Basics
http://developer.android.com/guide/topics/providers/content-provider-creating.html#ContentProvider - Implementing the ContentProvider Class
I suggest you first read those pages. Google is giving some more information about Content Providers, tutorials and examples:
http://android10.org/index.php/articlesdatastorage/252-content-providers-using-and-creating-them
http://thinkandroid.wordpress.com/2010/01/13/writing-your-own-contentprovider/
http://www.vogella.com/articles/AndroidSQLite/article.html
http://about-android.blogspot.com/2010/04/content-provider-example-1.html
There is no rule as such that you have to implement only one content provider per application. If your project demands, then you can do so.
If you want to implement multiple content providers in your application package, then make sure that authorities part of each content provider is unique, to route the incoming data requests to each content providers properly.
But having too many content providers can really confuse you and not required.
The only scenario that I see to have multiple content providers is, if you are having multiple databases in your application and you want to share all those databases with outside applications. Where you can use separate content provider for each database to share it with outside world.
Hope it helps.

Using content provider to fetch emails

I need to fetch and list the received emails in my own layout listview.
Is this possible through Content Provider?
There are no documented and supported content providers for "received emails". "Email" is not really a part of the operating system (though there are a few lingering references to it from back in the 2006-2007 timeframe when there was no clear distinction between the OS, apps, and the SDK). There are probably hundreds of email clients, only a few of which might have such content providers, and probably no standards between them.
You will find some blog posts and other answers here on StackOverflow that point you to a Gmail content provider. This is an example of an undocumented and unsupported content provider. It was also just closed off by Google.
You are welcome to write your own email client, store your own emails, and display them as you see fit, though.

Categories

Resources