开发者

Can I access downloaded files from an Android application

I want to build an application that is able to read .CSV files. These .CSV files are downloaded NOT from within the application but just the regular Android browser.

Now, when I start my custom application, is that dow开发者_高级运维nload available to me? Any examples?


Files downloaded with the browser on my HTC Hero ends up in /scard/download/. Other browsers might place the files in the same location. The files in that directory are available to your app just as any other files in the file system. Handle them as you would any other file.


Everything downloaded from the browser is stored in /sdcard/download.

  • Add the appropriate permission in the manifest:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
  • Get the path to the SDCard by using Environment.getExternalStorageDirectory() method.

  • Use Java's File() or some library to open the file.


DownloadManager has the ACTION_DOWNLOAD_COMPLETE intent that your Activity can listen for. This will notify you everytime a download completes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜