0

In my App, I need to browse for local/external storage HTML files and display them on a WebView.

How do I activate such Intent action to popup the build-in file manager and return a result as the full path to the file selected?

Cheers.

ZigiZ
  • 2,480
  • 4
  • 25
  • 41
  • Possible duplicated http://stackoverflow.com/questions/4452880/file-browsing-in-android http://stackoverflow.com/questions/4642469/how-to-browse-files-stored-on-android-sd-memory ,http://stackoverflow.com/questions/12672803/android-browse-files-code. – Raluca Lucaci Jan 15 '14 at 14:27

1 Answers1

1

There are no standard app doing that, you must write your own solution. You should use File.listFiles(); for listing files in given directory, together with Environment.getExternalStorageDirectory to get path to external storage.

marcinj
  • 48,511
  • 9
  • 79
  • 100
  • But surely the build in file manager CAN browse the SD card. Can't I use it as my Intent action? – ZigiZ Jan 15 '14 at 14:30
  • Never seen docs for it in api, you can find here sample implementation: http://code.google.com/p/android-file-dialog/ – marcinj Jan 15 '14 at 14:35
  • Very strange. I simply can't believe that there isn't a build-in "browse for file/dir" API in Android :/ Is there a reason for that? Is there an official document that confirm what you say? (I'm very new to Android development, sorry). I'll do some more digging my self... +1 in any case :) – ZigiZ Jan 15 '14 at 14:53
  • Maybe because each device manufacturer is creating his own UIs, and one general app from google would not look good on all those devices? Google could force manufacturers to write such file pickers but then again they would have different UI from your app UI - so it would look bad. In google play you can find lots of file managers, they allow to click on file and choose app they want to show it with, this is the other way around you want - but you may want to implement intent-filter to be able to view html file in such cases. – marcinj Jan 15 '14 at 15:01