I have application which generate PDF, then I put in folder A, how can I open and exploring all files in folder A when clicked button (showing new Intent)? I wish that my preview like when click My Files >> Folder A >> [files].
Asked
Active
Viewed 386 times
0
-
where is folder ? sdcard? – KOTIOS Dec 12 '13 at 06:58
3 Answers
0
This function will get you the sdcard root :
getExternalStoragePublicDirectory()
After getting the root you can create or open a folder.
to create a folder use
mkdir()
or
mkdirs()
functions.
to get all the files from that folder you can use File object.

Bhavin Parmar
- 33
- 6
0
Here is the example source code for file explorer in android : https://github.com/mburman/Android-File-Explore
Its very straightforward forward code

KOTIOS
- 11,177
- 3
- 39
- 66
0
Doe this code help? original source
String folderPath = Environnement.getExternalStorageDirectory()+"/A";
Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
Uri myUri = URI.parse(folderPath);
intent.setType("file/*");
startActivity(intent);
-
I got error when do this android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT – Agoeng Liu Dec 12 '13 at 07:18
-
replace intent.setDataAndType(myUri , "file/*"); with intent.setType("file/*"); – insomniac Dec 12 '13 at 07:21
-
it is working now, my fault is setType with Uri as parameter, thank you. – Agoeng Liu Dec 12 '13 at 07:31
-
is it possible also, when I choose one of them, then open my pdf file? I cannot open my pdf file directly – Agoeng Liu Dec 12 '13 at 07:36
-
Sorry i don't completely understand your question,anyway You can write an onActivityResult() function and instead of starting with just startActivity() call startActivityForResult() – insomniac Dec 12 '13 at 07:39
-
for your code, it is working now, it can show list of directory, but when I choose my folder, then get my pdf files, I cannot open it, is it possible to open? – Agoeng Liu Dec 12 '13 at 07:42
-
Yes you can that is what i said in the last comment,you can get the file Uri in the onActivityResult() and write code to read from a pdf file in that function,try to google onActivityResult() – insomniac Dec 12 '13 at 07:44
-
hello, i just follow your ways, and it is working, how can I get pdf file name when I choose it from the list? actually if I get pdf filename, i have no difficulties to read pdf onAcitivtyResult. – Agoeng Liu Dec 12 '13 at 08:00
-
let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/43018/discussion-between-insomniac-and-agoeng-liu) – insomniac Dec 12 '13 at 08:29
-
You need to goto this web page http://www.androidsnippets.com/get-file-path-of-gallery-image – insomniac Dec 17 '13 at 05:05