Android Question Dropbox integration

gadgetmonster

Active Member
Licensed User
Longtime User
Hi All

I have a requirement where files will get created by a desktop app in a users dropbox folder and I need to download these for processing. I tried to use the Dropbox Sync Library and this did indeed locate the files, and download them. However, once I have processed them, I need to delete them from Dropbox and have no idea how I can do this.

Can anyone shed any light?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this code to delete a remote file:
B4X:
Sub DeleteFile(RemoteDir As String, RemoteFile As String)
   Dim r As Reflector
   r.Target = manager
   Dim pth As Object = r.RunMethod3("getPath", RemoteDir, "java.lang.String", _
     RemoteFile, "java.lang.String")
   r.Target = r.GetField("fileSystem")
   r.RunMethod4("delete", Array As Object(pth), Array As String("com.dropbox.sync.android.DbxPath"))
End Sub
 
Upvote 0

Mikonios

Active Member
Licensed User
Longtime User
Hi Erel,
Is possible a "make directory" with the same system are you described ?..
How will be it, please ????
And. a "remove directory" at DBX ????
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try this:
B4X:
Sub CreateFolder(RemoteDir As String)
   Dim r As Reflector
   r.Target = manager
   Dim pth As Object = r.RunMethod3("getPath", RemoteDir, "java.lang.String", _
     "", "java.lang.String")
   r.Target = r.GetField("fileSystem")
   r.RunMethod4("createFolder", Array As Object(pth), Array As String("com.dropbox.sync.android.DbxPath"))
End Sub

The Delete method posted above should be able to delete folders.
 
Upvote 0

Mikonios

Active Member
Licensed User
Longtime User
Hi again,
Your code "createFolder" is perfect, but to deleteFolder don't work.
Are there any workaround ?????

B4X:
Sub DeleteFolder(RemoteDir AsString)
    Dim MiR AsReflector
    MiR.Target = Manager
    Dim pth AsObject = MiR.RunMethod3("getPath", RemoteDir, "java.lang.String", "", "java.lang.String")
    MiR.Target = MiR.GetField("fileSystem")
    MiR.RunMethod4("deleteFolder", ArrayAsObject(pth), ArrayAsString("com.dropbox.sync.android.DbxPath"))
End Sub

java.lang.NoSuchMethodException: deleteFolder [class com.dropbox.sync.android.DbxPath]
 
Upvote 0
Top