cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reading content from a file and show it WITHOUT downloading

Reading content from a file and show it WITHOUT downloading

cris3c
Explorer | Level 4

hi all,

 

Currently I am developing an Android App with Android Studio and I got Dropbox API to get information from Dropbox. I am blocked with a method to get information from Dopbox account (.txt, .html, .jpg whatever file is displayed there) and display it on the screen of the simulator without download that file in any folder (reading directly from Dropbox). I am new with the API, could anyone share with me an example code to archieve it? or send me any information about that.

 

Thank you.

13 Replies 13

Greg-DB
Dropbox Staff

To use the Dropbox API from an Android app, we recommend using the official Dropbox API v2 Java SDK

 

With that, you can use the download or downloadBuilder methods to access file data from the connected Dropbox account. 

 

There's an example of calling the download method in an Android app here.

 

While that example happens to save the file to the local filesystem, you are not required to do so. You can use the returned DbxDownloader to write to an OutputStream, using DbxDownloader.download, or get an InputStream of the file content, using DbxDownloader.getInputStream,  and then use that InputStream however you wish.

cris3c
Explorer | Level 4

I didn´t get it! Can please anyone help me out?

I am new on Android Studio, I need to know hoy to make the call from the On Create method, or life circle of the call.

 

Thanks!

Greg-DB
Dropbox Staff

@cris3c Did you see my comment from earlier? Please refer to the links there for a number of useful resources.

 

If something isn't working as expected, or you're stuck on something, perhaps you could share what you have so far and what problem you're currently seeing.

cris3c
Explorer | Level 4

Hi,

I have cloned the example code in my local and opened it with Android Studio. Reading your tutorial in the following link: https://github.com/dropbox/dropbox-sdk-java#authorize

I started to follow the steps to build from source and run the examples, I could not pass the first step. It said that: "Follow the instructions in the "Build from source" section above." and that means that you have to run gradlew build code but when I run that it does not work due to next error:

photo 1photo 1

Could you help me out, please? Am I following the steps properly?

 

Thank you.

Greg-DB
Dropbox Staff

Technically you don't need to build from source if you don't need to change the source code for the SDK (which you probably don't have reason to do). Instead, it's much easier to just install a released version. For example, you can replace this line from the Android example build.gradle:

    implementation group: 'com.dropbox.core', name: 'dropbox-core-sdk', version: '0-SNAPSHOT', changing: true

With this instead:

    implementation 'com.dropbox.core:dropbox-core-sdk:3.1.5'

Then once you do a Gradle sync for that change in Android Studio, it will download and install it for you. 

cris3c
Explorer | Level 4

Hi,

The code lines you told me work perfectly but I found another error. I think android studio does not find the executable run.exe. I attach the following terminal message. It is in spanish but it can be read easily. 

 

Could you help me out, please?

image.png

Greg-DB
Dropbox Staff

I see you're now attempting to run the "authorize" example, and are trying to do so via a "run" command. That's actually referring to this "run" file which is a bash script, so you'd need to be running in an environment that can run bash scripts (such as cygwin).

 

If you're just trying to build an Android app though, I recommend just referring to the Android example app. The "authorize" example is just a command line app.

cris3c
Explorer | Level 4

Hi, I was trying to run the example in an environment that does not support bash scripts. So as you said, I built the android example, but when I try to run it this error comes:

  • API 'variant.getMappingFile()' is obsolete and has been replaced with 'variant.getMappingFileProvider()'.
  • API 'variantOutput.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'.
  • src/main/java/com/dropbox/core/examples/android/DownloadFileTask.java
  • package com.dropbox.core.v2.files does not exist
  • cannot find symbol class FileMetadata
  • cannot find symbol class FileMetadata
  • cannot find symbol class FileMetadata
  • cannot access DbxClientV2Base class file for com.dropbox.core.v2.DbxClientV2Base not found
  • src/main/java/com/dropbox/core/examples/android/FilesActivity.java
  • package com.dropbox.core.v2.files does not exist
  • package com.dropbox.core.v2.files does not exist
  • package com.dropbox.core.v2.files does not exist
  • cannot find symbol class FileMetadata
  • cannot find symbol class FileMetadata
  • cannot find symbol class FolderMetadata
  • cannot find symbol class FileMetadata
  • cannot find symbol class ListFolderResult
  • cannot find symbol class FileMetadata
  • uses or overrides a deprecated API.
  • src/main/java/com/dropbox/core/examples/android/FilesAdapter.java
  • package com.dropbox.core.v2.files does not exist
  • package com.dropbox.core.v2.files does not exist
  • package com.dropbox.core.v2.files does not exist
  • cannot find symbol class Metadata
  • cannot find symbol class Metadata
  • cannot find symbol class Metadata
  • cannot find symbol class Metadata
  • cannot find symbol class FolderMetadata
  • cannot find symbol class FileMetadata
  • cannot find symbol class FolderMetadata
  • cannot find symbol class FolderMetadata
  • cannot find symbol class FileMetadata
  • cannot find symbol class FileMetadata
  • cannot find symbol class FileMetadata
  • cannot find symbol class FileMetadata
  • cannot find symbol class FolderMetadata
  • src/main/java/com/dropbox/core/examples/android/FileThumbnailRequestHandler.java
  • package com.dropbox.core.v2.files does not exist
  • package com.dropbox.core.v2.files does not exist
  • package com.dropbox.core.v2.files does not exist
  • cannot find symbol class FileMetadata
  • cannot find symbol class FileMetadata
  • cannot find symbol variable ThumbnailSize
  • cannot find symbol variable ThumbnailFormat
  • cannot find symbol method files()
  • src/main/java/com/dropbox/core/examples/android/GetCurrentAccountTask.java
  • package com.dropbox.core.v2.users does not exist
  • cannot find symbol class FullAccount
  • cannot find symbol class FullAccount
  • cannot find symbol class FullAccount
  • cannot find symbol class FullAccount
  • cannot find symbol method users()
  • src/main/java/com/dropbox/core/examples/android/ListFolderTask.java
  • package com.dropbox.core.v2.files does not exist
  • cannot find symbol class ListFolderResult
  • cannot find symbol class ListFolderResult
  • cannot find symbol class ListFolderResult
  • cannot find symbol class ListFolderResult
  • cannot find symbol method files()
  • src/main/java/com/dropbox/core/examples/android/UploadFileTask.java
  • package com.dropbox.core.v2.files does not exist
  • package com.dropbox.core.v2.files does not exist
  • cannot find symbol class FileMetadata
  • cannot find symbol class FileMetadata
  • cannot find symbol class FileMetadata
  • cannot find symbol class FileMetadata
  • cannot find symbol variable WriteMode
  • cannot find symbol method files()
  • src/main/java/com/dropbox/core/examples/android/UserActivity.java
  • package com.dropbox.core.v2.users does not exist
  • cannot find symbol class FullAccount

I think the error is in the packages. Could you please help me out?

Greg-DB
Dropbox Staff

This appears to indicate that the Dropbox library wasn't successfully loaded. Were you able to add it as instructed in my earlier comment? Did the Gradle sync complete successfully after that?

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    cris3c Explorer | Level 4
What do Dropbox user levels mean?