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

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?

Related

Android: How import contacts from device address book to my android app?

Android 4.3.
I write android application that show/edit/add/remove conacts that user input.
But I has many contacts in my adress book on device. So I want to imprort all this conacts from device adress book to my android application. How I can do this?
Use ContentProvider components in your application.
ContentProvider definition according to Android documentation:
Content providers can help an application manage access to data stored
by itself, stored by other apps, and provide a way to share data with
other apps. They encapsulate the data, and provide mechanisms for
defining data security.
Follow the link to learn about content provider
codetutor
else follow the vogella tutorial about contacts
you will use content resolver api to query your phone book and retrieve contacts list .this is useful
tutorial

Is particular bookmark a content provider?

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.

Search other apps content

I need to make an app, similar to Google Now, which would search other apps content that is exposed via Content Providers.
The problem I have, is that all resources I found talk about making your app searchable, but I need the opposite - how to search through all those apps? Is this a private API that only Google Now uses or can I also make such an app?
Currently, I managed to get a list of all searchable apps by reading all meta tags and filtering those with "android.app.searchable" but there must be a better way.
The logical flow should be:
find apps with "android.app.searchable" meta tag
read searchable.xml config to get the content provider
query the content provider from search box

When is a Custom Content Provider called for?

I have seen custom content providers for sqLite in apps, but thats about it. When should a Custom Content provider be built?
EboMike in this question says:
Other apps will be able to access your data.
You can wrap and abstract a lot of the query logic in your content provider, and limit access.
You will be able to lean on the system to allow for things like managed queries.
Remember that you can control user interacts with your data,for example you can prevent user from modifying data or you can force system to open data with explicit App and so on.

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.

Categories

Resources