I have two apps and I want one app to change preferences in another app.
Is it possible? If so, then how?
It means that you need some passage between two applications.
If A application provides content provider, B application can access that content provider and change values in that provider.
Have a look this article http://developer.android.com/guide/topics/providers/content-providers.html
You could use Content Providers. Put your settings in a database so that the other application can read.
Related
i have two or more applications.
one of them is the base application and the others are just extensions(add-on).
i want when user install base Application and after that user install other extensions of applications, some features be enable in my base app. something like Go launcher App. if u want to use go launcher themes you should install themes and you will allow to use themes in go launcher app.
is it possible in android?
if it is what do u suggest?
thanks for any suggestion.
Use Content Provider to achieve your task.
This example contains two applications like parent and child. it performs data sharing, database in parent application and child can access parent database using content provider.
Refer This Link: http://www.compiletimeerror.com/2013/12/content-provider-in-android.html#.V4STZjVazDc
aidl meet your needs ! App1 call App2 method use binder
I have two applications and I want to be able to share a String value between them. For example: user changes the String in app A, when app B is launched, I want it to read the updated String (and vice versa).
I was trying to use SharedPreferences with Context.MODE_WORLD_WRITABLE, but it's been deprecated.
How can I achieve this?
EDIT: App A has to save the value without launching app B. App B has to be able to read that value without launching app A.
I looked at ContentProviders, but they look too complex, especially for a simple String sharing.
One option is use webserver for this. for example store value in web server from app1 and access this value from app2
option two is use content providers. Through the content provider, other apps can query or even modify the data (if the content provider allows it)
Simply put:
one application needs to send intent with data
the other one needs to listen for it with brodcast receiver.
Content provider is probably not the thing you are looking for.
here is good tutorial for brodcast receiver
Try http://developer.android.com/training/sharing/send.html or http://developer.android.com/guide/topics/providers/content-providers.html to share data between 2 applications
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.
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.
I’m a beginner to Android development. Something always confuses me. Let say if I want to create a simple app that shows all presidents of United States with some brief info, how do I store this information? Should I store these information in content provider while activity oncreate? Doesn’t it append the data everytime when user start this activity?
Should I store these information in content provider while activity oncreate?
You never store data in a content provider... a content provider is used in order to (guess what?), provide content. In most cases you won't need to create your own content provider; unless you want to share that data with other apps. If the information you are going to handle is going to be used by your app only, don't create content providers... just put your data in a database and access it from there.