Reputation: 29
i'm newbie of android.My goal is this: i have to enable different apps to share primitive data securely.
App 1 retrieves data for remote resources and save it (it's the data owner). App 2, App 3, ... have to be able to retrieve the data stored by App 1.
How to share this data securely? It's important for me avoid foreign apps installed on the device to retrieve this data.
Thanks in advance
Upvotes: 0
Views: 105
Reputation: 39992
When applications share the same user id and are signed by the same entity, the can shared data. Then you just use the regular internal shared storage.
In the manifest, set the shared user id:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="string"
android:sharedUserId="string"
android:sharedUserLabel="string resource"
android:versionCode="integer"
android:versionName="string"
android:installLocation=["auto" | "internalOnly" | "preferExternal"] >
. . .
</manifest>
http://developer.android.com/guide/topics/manifest/manifest-element.html#uid
The internal storage example is:
String FILENAME = "hello_file";
String string = "hello world!";
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();
http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
EDIT I don't know why having access to all the data is a bad thing. You DO own the apps so you control what they do. If you really want to limit the data that is shared, use a ContentProvider with Permissions that limit access or at least let the user decide who access it, AND encrypt the data. Alternatives: Store this data on a remote server and let each application sync that data into its own secure private storage.
How to restrict content provider data across applications
Upvotes: 1