[android-developers] Sharing data between apps
I've been looking to see if there is a relatively simple way for 2 apps to share a tiny bit of data. So far, I haven't found any. 1) SharedPreferences - aren't shared. 2) MemoryFile in Shared Memory - there appears to be no way to share these between apps. 3) Internal Storage - separate apps can't write to each others area, even if they have the same userid. 4) External storage - may not exist. So, in order to send 10 bytes of data to another app, it seems that I'll have to create a new Activity and have it respond to an Intent(). Is that really the only way to do this? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Sharing data between apps
Activity, BroadcastReceiver, ContentProvider, or Service. On Wed, Jan 12, 2011 at 2:58 PM, John Lussmyer johnlussm...@gmail.comwrote: I've been looking to see if there is a relatively simple way for 2 apps to share a tiny bit of data. So far, I haven't found any. 1) SharedPreferences - aren't shared. 2) MemoryFile in Shared Memory - there appears to be no way to share these between apps. 3) Internal Storage - separate apps can't write to each others area, even if they have the same userid. 4) External storage - may not exist. So, in order to send 10 bytes of data to another app, it seems that I'll have to create a new Activity and have it respond to an Intent(). Is that really the only way to do this? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Sharing data between apps
On Wed, Jan 12, 2011 at 5:58 PM, John Lussmyer johnlussm...@gmail.com wrote: 3) Internal Storage - separate apps can't write to each others area, even if they have the same userid. AFAIK, they can. What proof do you have to the contrary? Not that this is particularly a good strategy for SDK apps, mind you. So, in order to send 10 bytes of data to another app, it seems that I'll have to create a new Activity and have it respond to an Intent(). That is not the proper use of an Activity. Is that really the only way to do this? -- Create a service, exposing an API through AIDL, consumed via bindService() -- Create a service, exposing an API through an Intent (sent via startService()) and returning results via a Messenger, or createPendingResult()'s PendingIntent, etc. -- Create a content provider There may be other options depending on what the 10 bytes of data actually is, but those should get you started. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android App Developer Books: http://commonsware.com/books -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Sharing data between apps
On Wed, Jan 12, 2011 at 4:53 PM, Mark Murphy mmur...@commonsware.comwrote: On Wed, Jan 12, 2011 at 5:58 PM, John Lussmyer johnlussm...@gmail.com wrote: 3) Internal Storage - separate apps can't write to each others area, even if they have the same userid. AFAIK, they can. What proof do you have to the contrary? Not that this is particularly a good strategy for SDK apps, mind you. You can't specify a path in the call to openFileOutput(). (Fails if there are any path separators) Hard to specify another apps directory if you can't use path separators. So, in order to send 10 bytes of data to another app, it seems that I'll have to create a new Activity and have it respond to an Intent(). That is not the proper use of an Activity. Is that really the only way to do this? -- Create a service, exposing an API through AIDL, consumed via bindService() -- Create a service, exposing an API through an Intent (sent via startService()) and returning results via a Messenger, or createPendingResult()'s PendingIntent, etc. -- Create a content provider There may be other options depending on what the 10 bytes of data actually is, but those should get you started. 10 bytes of data is 10 bytes of data. 10 binary bytes. Not text. Only needs to be transferred occasionally, but does need to be transferred. So, what you are saying is there is NO easy way to transfer a tiny bit of data. App X just needs to send it to App Y when the user does certain actions. sigh. (In this case there are 2 apps, either of which can be used independently, but if both are on the phone, they can work together.) A SharedPreference would have been perfect - but the Shared prefix seems to have a different meaning than what you would think. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Sharing data between apps
On Wed, Jan 12, 2011 at 8:35 PM, John Lussmyer johnlussm...@gmail.com wrote: You can't specify a path in the call to openFileOutput(). Don't use openFileOutput(), then. Hard to specify another apps directory if you can't use path separators. You can use path separators in Android. You just cannot use path separators in openFileOutput(). That's one reason why I don't use openFileOutput(). Just use standard Java I/O. There may be other options depending on what the 10 bytes of data actually is, but those should get you started. 10 bytes of data is 10 bytes of data. Not really, but you are certainly welcome to your opinion. App X just needs to send it to App Y when the user does certain actions. Use a broadcast Intent and a BroadcastReceiver. Or any of the approaches I mentioned earlier. A SharedPreference would have been perfect - but the Shared prefix seems to have a different meaning than what you would think. They are shared among components in an app. They are not shared between applications, between devices, between neighboring countries, or between consenting adults. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android App Developer Books: http://commonsware.com/books -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Sharing data between apps
On Wed, Jan 12, 2011 at 6:18 PM, Mark Murphy mmur...@commonsware.comwrote: On Wed, Jan 12, 2011 at 8:35 PM, John Lussmyer johnlussm...@gmail.com wrote: 10 bytes of data is 10 bytes of data. Not really, but you are certainly welcome to your opinion. Now this has me curious. What definitions of data would make a difference? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Sharing data between apps
Your apps are in two different sandboxes. They are protected from themselves, just like they are protected from other apps. That's the way it is. SharedPreferences doesn't mean a big data pool that all of the applications installed on the device share. It is just shared amongst the components of an app. You've been given the 4 main components used for interaction between two apps. 10 bytes is pretty small, so any of those will be totally sufficient to get 10 bytes from here to there. Just use one of them. A broadcast receiver is probably the easiest. On Wed, Jan 12, 2011 at 5:35 PM, John Lussmyer johnlussm...@gmail.comwrote: On Wed, Jan 12, 2011 at 4:53 PM, Mark Murphy mmur...@commonsware.comwrote: On Wed, Jan 12, 2011 at 5:58 PM, John Lussmyer johnlussm...@gmail.com wrote: 3) Internal Storage - separate apps can't write to each others area, even if they have the same userid. AFAIK, they can. What proof do you have to the contrary? Not that this is particularly a good strategy for SDK apps, mind you. You can't specify a path in the call to openFileOutput(). (Fails if there are any path separators) Hard to specify another apps directory if you can't use path separators. So, in order to send 10 bytes of data to another app, it seems that I'll have to create a new Activity and have it respond to an Intent(). That is not the proper use of an Activity. Is that really the only way to do this? -- Create a service, exposing an API through AIDL, consumed via bindService() -- Create a service, exposing an API through an Intent (sent via startService()) and returning results via a Messenger, or createPendingResult()'s PendingIntent, etc. -- Create a content provider There may be other options depending on what the 10 bytes of data actually is, but those should get you started. 10 bytes of data is 10 bytes of data. 10 binary bytes. Not text. Only needs to be transferred occasionally, but does need to be transferred. So, what you are saying is there is NO easy way to transfer a tiny bit of data. App X just needs to send it to App Y when the user does certain actions. sigh. (In this case there are 2 apps, either of which can be used independently, but if both are on the phone, they can work together.) A SharedPreference would have been perfect - but the Shared prefix seems to have a different meaning than what you would think. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en