Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share data between users on multi-user Android (4.2 or later)

Tags:

android

Android introduced the Multiple Users feature in 4.2 (Jelly Bean MR1) and its documentation states:

From your app’s point of view, each user is running on a completely separate device.

And here is a quote from the Environment.getExternalsStorageDirectory() and getExternalStoragePublicDirectory() methods doc:

On devices with multiple users (as described by UserManager), each user has their own isolated external storage. Applications only have access to the external storage for the user they're running as.

Could it be true that there really is no reliable way to communicate data between users on a single device without using the network as mediator? I'm looking for solutions that don't rely on quirks of how the device's file system is laid out by a manufacturer. Also, for security, the sharing should be internal to my app.

Even if file sharing is indeed impossible, is communication via intents somehow possible?

There are use cases for this. Use Case 1: let's say I'm writing an input method app that requires a 100MB dictionary file. I'd like to code things so that if User A downloads this file, then User B can access it also without needing to re-download. Use Case 2: let's say I'm writing a fun Leave My Wife a Note app that allows User A to type messages that will appear next time User B logs in (without using the network).

This thread on a separate site proposes a solution, but their method seems undocumented and possibly unreliable. And there are a few other SO questions that have a title similar to this one but are actually discussing different topics.

like image 344
Jo Jo Avatar asked Feb 19 '14 07:02

Jo Jo


People also ask

How do I share files between Android profiles?

the steps: In work profile via internal "Files" app select the file and use "Share" option. In Share dialog switch to "Personal profile" sharing options. Select file manager app.

How does multi user work on Android?

Android supports multiple users on a single Android device by separating user accounts and application data. For instance, parents may allow their children to use the family tablet, a family can share an automobile, or a critical response team might share a mobile device for on-call duty.


2 Answers

OBB Folder (/sdcard/Android/obb) is used to share files and folder between the multi users. But OBB folder not shown in my second user (One plus 5 mobile). So I have tried to create an OBB folder in Android folder (/sdcard/Android/) in second user and "BOOM" it worked. Now i am able to access the shared files in second user. Try this trick if OBB folder not shown in your second user.

like image 117
Prasaathviki Avatar answered Sep 22 '22 16:09

Prasaathviki


OBB files (stored in /sdcard/Android/obb) and used as expansion files in Google Play are shared between all users by design, as they are fairly large. If you Input method uses expansion files, the downloaded data will be shared automatically. You can send broadcasts to other users but that requires the INTERACT_ACROSS_USERS permission, which is reserved for system applications.

like image 26
Nikolay Elenkov Avatar answered Sep 18 '22 16:09

Nikolay Elenkov