this is the first time I'm taking a look at the Dropbox API so I'm afraid I kinda don't understand much.
My purpose is to develop an App in which I place some files into a directory so as to be automatically uploaded to the server and synced in another device whose owner I'm sharing them with, so different accounts are being used of course.
In the end, it has to be something similar to Dropbox app itself: you are able to create a file, upload it and share it with some friends.
Any idea if this is possible, what to begin with, is it possible to use for this goal any folder i want or it has to be one particularly chosen by Dropbox...?
If you're asking for a way to programmatically share a folder with another user, the API doesn't currently support that. To do what you're doing, you would need to manually (with the Dropbox app or via dropbox.com) share a folder with the other user. From then on, you could use the Dropbox API to read from and write to that shared folder. (And the same would work from the other account, since the folder would be visible to both of you.)
Related
I want to share app specific directory(/data/data/packageName/files/target) and its children to other (my) app.
These are my scenarios and conditions.
App A creates and downloads random files on /data/data/packageA/files/target
App B wants to retrieve and delete /data/data/packageA/files/target recursively without user interaction. (SAF is not an option)
All apps are mine.
Shared storage(ex. /emulated/0/Documents etc) is not an option.
sharedUserId using createPackageContext works perfect for me, but it is deprecated.
Is there any solution to solve this problem?
EDIT: I'm looking for the way not to manage nor inspect every files creating structed data like StorageProvider Sample. I wish App B could access files dynamically with only root directory (target in this example)
I want to add a functionality to my app to treat a user's uploaded images online as if they were files on their phone, so all their existing apps can find their images without needing to download them all. Basically tricking the phone into thinking its local instead of online. Any thoughts and how to go about this?
i have developed a android app for farmers. it is a informative app for indian farmer.The users will be sending me the images and video files to me through my app. here i used (integrated) dropbox to receive those files directly to my dropbox space. whatever the image or video taken by the user, it will be stored on a folder in my mobile storage. Here what i want is, i want the folder in my mobile storage to be in sync with the folder in my dropbox.
How can i do this?
there is a app in market called Foldersync which exactly fulfil my requirement. how they are doing it? How can i keep a folder in my mobile storage and a folder in my dropbox to be in Sync?
Note :
i have gone through drop-box api and created a simple app to send files directly to my dropbox space and i know how to download a entire folder from dropbox.
But here my question is unique from that... pls don't answer the above points which i already know..
Please help!
Thank You
You can use the Dropbox API to keep a local client in sync with Dropbox. There are two main pieces to this:
1) Metadata:
Assuming you're using the Core API, the best way to get information about all of the file and folders in an account (or optionally under a specific path) is to use /delta:
https://www.dropbox.com/developers/core/docs#delta
With this, you can get information about everything your app can see, and then easily stay up to date with changes. There are some useful blog posts on using /delta here:
https://blogs.dropbox.com/developers/2013/12/efficiently-enumerating-dropbox-with-delta/
https://blogs.dropbox.com/developers/2013/12/filtering-dropbox-delta-results-by-path/
2) File content:
Using the metadata retrieved from #1, you can download any files you need access to locally using /files (GET):
https://www.dropbox.com/developers/core/docs#files-GET
You can upload locally changed files using /files_put:
https://www.dropbox.com/developers/core/docs#files_put
Or, for larger files, use chunked uploading:
https://www.dropbox.com/developers/core/docs#chunked-upload
https://www.dropbox.com/developers/core/docs#commit-chunked-upload
The main work here will involve programming the logic in your app to correctly receive changes from the server as well as upload local changes, in order to keep everything in sync.
Also, be aware that on mobile devices, bandwidth can be limited and/or expensive, so be careful to not accidentally automatically download a lot of data the user doesn't want or need.
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 !
I know that similar questions have been posted before, but I believe there has not been an answer for my exact use case.
I have a trial and a full version of my Android app. When the user buys the full version, both versions should share their settings. Changes in one app should show up in the other app as well. When one app is un-installed, the settings shall be preserved for the other app. It's not a one-time import because the user might not uninstall the trial app and could even continue using it.
Both apps use the same shared user id and run in the same process. However, when I call getFilesDir(), the directory returned contains the package name of the app, so the directories for storing files used by the two apps differ. How can I have both apps use the exact same file without using external storage?
How can I have both apps use the exact same file without using external storage?
That will not meet your objective:
When one app is un-installed, the settings shall be preserved for the other app
Given that objective, by definition, you cannot be using a single file that will be removed on uninstall, as if the user uninstalls that app, the other app is broken.
Your choices are:
Use external storage, specifically not getExternalFilesDir() or getExternalCacheDir(), or
Have each app maintain its own copy of the file, using some mechanism to keep the changes in sync, or
Switch to in-app purchases, so you do not have separate free/paid apps, or
Abandon your "both apps should share their settings" objective
You need to save those preferences either to a file or database if you want them to remain after the process containing all the components close.
A quick way, if you have this in your control, is to change all the uid's for your applications to the same and use the file api's for reading and writing from a file or the database. Using a database is just a step away from using a content provider though... which is probably the correct most solution.