I have an app on Android & iOS, say ABC. It stores and accesses SQLite database (.db file) which is local to user's device.
To provide sync among different devices, I implemented Dropbox Sync API so that data entered on one device gets reflected on other devices automatically. Of course, the user must have linked the app ABC to their Dropbox account on all devices. So, its the same Dropbox account on all devices.
The SQLite database gets stored in app folder (Dropbpx/Apps/ABC). I have taken permission for app folder only.
Now, I wish to implement multi-user feature with read/write permissions where users with different Dropbox accounts can access this app folder (Dropbpx/Apps/ABC). It seems app folders can't be shared. (When I try to share an app folder, it says 'An app folder can't be shared')
This link says you need Full Dropbox permissions to create a shared folder, but Sync API doesn't support Full Dropbox permission.
Any clues how can I provide multi-user feature (sharing a folder, .db files) with Sync API?
Any help would be appreciated.
The linked forum thread is still correct that the Sync API doesn't currently support the Full Dropbox permission. It's also correct that app folders are currently incompatible with shared folders (i.e., app folders can't be shared, or contain or be contained in shared folders.)
However, there is a new permission, called File Type, introduced after that thread, that the Sync API supports and can be used with shared folders. You can find more information about the different permissions here:
https://www.dropbox.com/developers/reference/devguide#app-permissions
Also, while .db isn't one of the standard extensions available in the File Type permission buckets, Dropbox API support can enable custom extensions as noted here:
https://www.dropbox.com/developers/support#custom-extensions
Related
The application I'm currently working on requires a manual setup (entering some information) on device provisioning. This information needs to be written to a file that should not be deleted when the application is uninstall or the application data is wiped (user support requirement, as they can direct users to do this in some cases)
There was a very similar old question, but the answer is now deprecated and no up-to-date answer has been posted
Keep files after uninstallation of android app
So the question is, given the deprecation of Environment.getExternalStorageDirectory() on Android 10, how do we programmatically write/read a file that will not be deleted when the application is uninstalled or the data is wiped?
For what is worth, we can not rely on app auto backup, as the users don't have google accounts configured.
Thanks
To summarize while targetting 30.
For Android 10 device: Request legacy external storage to get external storage access as usual.
And Googles step back for Android 11 devices: use directories like Download, Pictures, Movies, Documents, DCIM and so on. Read and write access for all. Android OS is very picky to use the right extensions for files to be created in those folders.
Android Q will introduce a new sandboxed filesystem for apps, Scoped Storage. This policy will be enforced on any apps targeting API>=29. How should a thrid-party file manager app get through this restriction and continue to work properly?
This question is meant to be generic for any apps that have some file-managing functionalities, like browsing, saving, loading, syncing, etc.
I believe your question is equivalent to: How app can get access to main phone storage (usually /sdcard)?
The answer is: ask user for access to the whole /sdcard using ACTION_OPEN_DOCUMENT_TREE action. That way your app can access /sdcard and all its subdirectories.
From https://developer.android.com/preview/privacy/scoped-storage#manage-groups-of-files :
File management and media creation apps typically manage groups of files in a directory hierarchy. These apps can invoke the ACTION_OPEN_DOCUMENT_TREE intent to allow the user to grant access to an entire directory tree. Such an app would be able to edit any file in the selected directory, as well as any of its sub-directories.
Using this interface, users can access files from any installed instance of DocumentsProvider, which any locally-backed or cloud-based solution can support.
There is also sample project on Github showing how it is done: https://github.com/android/storage/tree/228c8e0aa19586bfcf36318ddb191719537a45a4/ActionOpenDocumentTree
That's what "Files by Google" is currently doing on Android Q beta: https://www.androidpolice.com/2019/04/08/scoped-storage-in-android-q-beta-2-limits-how-apps-can-access-files/#1
in google drive, there's a tab named "backups" that contains data from old android phones I have.
These backups are not downloadable.
Is there a way to download these backup files? is there a way to get the information inside the backup files? ( API requests )
I know that for the Whatsapp backup-file there is a different API (because it's not downloadable like the others).
There's no mention of accessing the backup folder in Drive API. But, if you're referring to a special folder called App Folder which is only accessible by your application, then you can. Check the Get authorization to use the App Folder.
I tried following both the documentation:
https://developers.google.com/drive/android/pinning
And the demo:
https://github.com/googledrive/android-demos/blob/master/app/src/main/java/com/google/android/gms/drive/sample/demo/PinFileActivity.java
but I am still very confused on how to sync a pinned file between my local device and Google Drive.
According to the documentation:
Pinning a file causes the latest version of that file's contents and metadata to be downloaded to the local device whenever a new version is available.
I implemented the code provided, but they only show to set a file as "pinned" without more explanation.
When and where do we specify where those pinned files must be downloaded on the local device?
I created test files that are well listed in the remote Google Drive, but I have no idea how those pinned files can be retrieved automatically on the local device as explained in the guide.
The demos provided are just too simple and limited...
I actually succeeded to accomplish what I wanted, I had to understand how it worked through several tests.
In my app I actually use the specific app folder to interact with Google Drive:
Drive.DriveApi.getAppFolder(mGoogleApiClient)
This folder on Google Drive is accessed by the app only.
At first I thought I had to specify a folder on my device to indicate where the files from the Google Drive app folder should be downloaded but it does not work that way.
You just have to access this app folder directly and check if there were any changes inside it since the last time it was accessed.
So basically when the files were changed I copy them where I need in my app file structure.
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.
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.
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.
I also had the same question, and have tried various approaches such as using /sdcard/Android/obb but it does not work in Android 10. So I followed below approach, and I am able to copy files seamlessly between users.
Login to the User from where you would like to copy files from (lets call U1)
Run FTP Server using any application of choice like MiXplorer / ES Explorer etc... Note down the details of the port#, username, password etc... and point it to /sdcard
Switch user, to where you want to copy files to (lets call U2)
Install the FTP browser. If you use MiXplorer / ES Explorer, they will allow you to add a FTP share
Use ftp://localhost:2121 assuming the port is 2121, if not change it accordingly and add the FTP share
Open the FTP share and you can see all the files & folders of U1 here
Copy across to your heart's content !