3

I am working on an Android application which opens folders,

My question is how can I open a folder programmatically in Android? .

I tried all the solutions available in stack-overflow and searched in Google but I couldn't find a solution. Can someone please provide me an answer?

Thanks in advance.

Dan O
  • 6,022
  • 2
  • 32
  • 50
SLH_IB
  • 699
  • 1
  • 6
  • 14
  • Define what you mean by opening a folder. Get a list of files in it? Something else? – Gabe Sechan Jun 30 '14 at 19:19
  • @GabeSechan he says open a folder. what it matters what is inside the folder. I think he need to content to display inside the folder like when we click on a folder in general. – SMK Jun 30 '14 at 19:23
  • https://code.google.com/p/filebrowserandroid/source/browse/trunk/src/org/moo/android/filebrowser/FileBrowser.java?r=9 – Josef E. Jun 30 '14 at 19:24
  • I mean when i set uri path for a specific folder like "Download" then my application can open the folder ? , i'm sorry for ambiguous – SLH_IB Jun 30 '14 at 19:27
  • @SMK yes this what i mean in my question, thank you – SLH_IB Jun 30 '14 at 19:29
  • You didn't google it. I mean, seriously. A simple search for 'Android Directorychooser code example' resulted in thousands of sample codes. – Joao Guilherme Jun 30 '14 at 19:30
  • @Saleh_IB you may need to refer this http://stackoverflow.com/questions/18097763/how-to-open-the-my-files-folder-in-android-programatically-using-intent?rq=1 this might be what you need – SMK Jun 30 '14 at 19:33
  • @Wamasa, I google it before i post my question here, and there are in stackoverflow much questions like my questions but i can't find anything. So i post my question – SLH_IB Jun 30 '14 at 19:35
  • @Saleh_IB ok, heres what you need [link](https://github.com/passy/Android-DirectoryChooser) – Joao Guilherme Jun 30 '14 at 19:39
  • Ok @Wamasa thanks a lot for your help and all replies, i will try the all suggestions and i will post here what can i do for that. – SLH_IB Jun 30 '14 at 19:47

1 Answers1

0

you can open folder with use of following code

File file = new File(path);
        Uri uri_path = Uri.fromFile(file);
        String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension
                (MimeTypeMap.getFileExtensionFromUrl(path));


        Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
        intent.setType(mimeType);
        intent.setDataAndType(uri_path, mimeType);
        startActivity(intent);
Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96