Search code examples
javaandroidandroid-intentsynchronizationdropbox

Uploading file to dropbox (via syncing)


Scenario:
I want to download a file to from DropBox account, and edit it in Offline ( i.e, without internet connection) mode, and when user comes back to Online mode, this file needs to be uploaded to Dropbox account.

Also

I am done with downloading and uploading the file both.

Question:
But i want to know if their is any provision like, i can send an Intent to DropBox application and let the drop box do the uploading stuff. So that i will reduce my work to half.


Solution

  • You can use the chooser for ACTION_SEND with

    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("file/*"); 
    i.putExtra(Intent.EXTRA_STREAM, Uri.parse(filePath));  
    startActivity(Intent.createChooser(i, "Upload file");
    

    Or explicitly get the Intent via PackageManager.getLaunchIntentForPackage() for the Dropbox package com.dropbox.android.