cn1 - download file to phone's download directory

ygesher

I'm trying to allow an app to download files to the public 'Downloads' directory so it's available on the device in a generic fashion. I succeeded in downloading the files in the simulator to the .cn1 directory on my computer, but I couldn't find a straightforward way to get the file into a public directory on the device. I really expected there to be a method in the FileSystemStorage class that would allow this, but none of them seem to be what I'm looking for.

So I tried writing a simple native bridge to get the path to the public directory, starting with Android. I have a very simple class that looks like this:

public class DownloadDirectoryImpl {

    public static String getDownloadDirectory(){
        return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
    }

    public boolean isSupported(){
        return true;
    }
}

The app compiles fine, but when I click on the file to download it, I see the same line repeating itself in the logcat a few thousand times:

W/System.err:     at net.gesher.downloadDirectory.NativeDownloadDirectoryImpl.getDeviceDownloadDirectory(NativeDownloadDirectoryImpl.java:20)

But it doesn't state what the error is.

So, I'm looking for advice either a) to improve my android code so that it works, or b) the cn1 proper way of getting this directory path.

Thanks a ton!

Shai Almog

If you have a lot of lines saying at... and all refer to the same method then you have a recursive call leading to a stack overflow. Since the only method you mentioned is your native method I'm assuming you called your own method within the native implementation and got into a recursive loop.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

How to download the current document's innerHTML as a file?

来自分类Dev

S3Transfer download_file错误了,但是client.download_file正常工作

来自分类Dev

Javascript - Download CSV as File

来自分类Dev

File download in struts 2

来自分类Dev

Php - Secure File Download Facility

来自分类Dev

click on "download" link using JQuery doesn't download file

来自分类Dev

Struts 2 Download File is 0 bytes

来自分类Dev

Download.file在RStudio中失败

来自分类Dev

file upload download using WCF rest

来自分类Dev

Python: generate xlsx in memory and stream file download?

来自分类Dev

使用download.file同时下载

来自分类Dev

download.file()下载损坏的xls

来自分类Dev

RHEL6 Unable to download kickstart file

来自分类Dev

Download.file在RStudio中失败

来自分类Dev

_download file_最新版本的GitHub URL?

来自分类Dev

Download file from the internet, HttpSendRequest fails with error code

来自分类Dev

How to download file in jQuery (already use href with preventDefault)?

来自分类Dev

Force download instead of streaming of mp3 file in FF

来自分类Dev

How to do a progress bar to show progress download of a big file with AndroidAnnotations?

来自分类Dev

download.file不支持的URL方案中的错误

来自分类Dev

How to download and save a file from the internet using Scala?

来自分类Dev

Cannot download file from URL with international characters in the name using DownloadManager

来自分类Dev

使用“ download.file”功能下载多个文件

来自分类Dev

使用download.file()从HTTPS下载文件

来自分类Dev

_download file_的最新版本的GitHub URL?

来自分类Dev

使用 download.file 从 R 中的 URL 下载 zip 文件

来自分类Dev

来自 https 的 Ruby download_file 丢弃 RuntimeError

来自分类Dev

ActiveXObject to download directly to HDD

来自分类Dev

collectionfs generate download url

Related 相关文章

  1. 1

    How to download the current document's innerHTML as a file?

  2. 2

    S3Transfer download_file错误了,但是client.download_file正常工作

  3. 3

    Javascript - Download CSV as File

  4. 4

    File download in struts 2

  5. 5

    Php - Secure File Download Facility

  6. 6

    click on "download" link using JQuery doesn't download file

  7. 7

    Struts 2 Download File is 0 bytes

  8. 8

    Download.file在RStudio中失败

  9. 9

    file upload download using WCF rest

  10. 10

    Python: generate xlsx in memory and stream file download?

  11. 11

    使用download.file同时下载

  12. 12

    download.file()下载损坏的xls

  13. 13

    RHEL6 Unable to download kickstart file

  14. 14

    Download.file在RStudio中失败

  15. 15

    _download file_最新版本的GitHub URL?

  16. 16

    Download file from the internet, HttpSendRequest fails with error code

  17. 17

    How to download file in jQuery (already use href with preventDefault)?

  18. 18

    Force download instead of streaming of mp3 file in FF

  19. 19

    How to do a progress bar to show progress download of a big file with AndroidAnnotations?

  20. 20

    download.file不支持的URL方案中的错误

  21. 21

    How to download and save a file from the internet using Scala?

  22. 22

    Cannot download file from URL with international characters in the name using DownloadManager

  23. 23

    使用“ download.file”功能下载多个文件

  24. 24

    使用download.file()从HTTPS下载文件

  25. 25

    _download file_的最新版本的GitHub URL?

  26. 26

    使用 download.file 从 R 中的 URL 下载 zip 文件

  27. 27

    来自 https 的 Ruby download_file 丢弃 RuntimeError

  28. 28

    ActiveXObject to download directly to HDD

  29. 29

    collectionfs generate download url

热门标签

归档