Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing String data between Android applications

What is the best way to pass simple data such as a String between applications? The String is some field that is known in the sender app and is needed by the receiver app.

I looked into storing it in a MODE_WORLD_READABLE SharedPreferences, but I won't necessarily know the package name (this would exist in a library), the value can be set by various apps, so it'd be difficult to look up.

I was thinking have both apps contain BroadcastReceivers. When the receiver app is opened, it sends a custom Intent for the sender app to receive to tell it that it's ready to receive. Upon seeing that Intent, the sender app then sends another Intent with my string value to the receiver app to get.

like image 860
nicobatu Avatar asked Jun 23 '26 22:06

nicobatu


1 Answers

@CommonsWare What you're saying is incorrect. You can share data, for example a string between two applications. Please take a look here: Data sharing between two applications and also: http://developer.android.com/training/sharing/send.html

"I was thinking have both apps contain BroadcastReceivers." This is not needed. Google provides a very simple and easy solution and example.

like image 190
Noman Arain Avatar answered Jun 25 '26 12:06

Noman Arain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!