takecare
takecare

Reputation: 1893

Android Filesystem (sharing files across apps, via service)

I'm having a rough time figuring out what would be the best way to do the following: I'm building a library to be used by different apps. This library provides a user system, through a service, that is started by a "manager app" (used to log-in, add users, etc.).

I need to provide a facility for sharing files across apps.

Imagine that we have an application called APP XPTO. This APP need to store some files (it could be voice recordings, for this example). But It should not do so in its private application space (provided by Android, by default). It should be on a space that is accessible to the manager app (or the service if you will). Also, these files need to be encrypted, since I'm providing a multi-user system through the service, but I don't want to face privacy issues.

I thought of having the service manage this file system (FS) abstraction, by creating a class for representing a file:

class MyFile { // make it parcelable
    private String fullpath;
    private byte[] data;
    private User user;
}

And providing basic FS usage through intents.

APP XPTO could send an intent asking for a file, providing, in the intent, its path and the username it "belongs" to. The service would look for the file, decrypt it by using the user key (identified by the username), and create a new MyFile object to put it in the intent and send it to APP XPTO.

This way the files can be stored in a "private app space", since they will be served by the service. Right?

This seems a "little bit" odd, however. I know that Android isn't a multi-user OS (although that is being addressed) and that this idea, alone, goes against at least one of the Android's security mechanisms (the "private space" for each app), but I need this to work, this or something similar. It also seems to me that serving files through intents is somewhate "strange"...

Any observations, or ideas?

Upvotes: 0

Views: 422

Answers (1)

Sameer
Sameer

Reputation: 4389

To share data among different applications on Android use ContentProvider

Instead of Service, you will implement a ContentProvider. The users of the data can call the provider through ContentResolver

Upvotes: 1

Related Questions