1

I'm having a big problem with this. Getting the image, video and audio is not so hard but what if I like to get the non media type i want to display every non media type in a grid view or list view but can I do it? Anyone have idea in getting the uri and id of the non media files?

NewDroidDev
  • 1,656
  • 5
  • 19
  • 33

2 Answers2

1

I'm sure you are going to find that you are looking for in the answer to this question: MediaStore - Uri to query all types of files (media and non-media)

Community
  • 1
  • 1
  • I already used that it works on android jellybean but the problem there when i using that code and try to test to lower version the application is crashing – NewDroidDev Jul 11 '13 at 05:23
0

To get the information of any file in Android, we can use the File class.

The File class has a number of methods to get the information from some file. To use any of these, you must create a File object containing the name of the file (path) in which to work.

Should be noted that the creation of an object of type File has no permanent effect on the file system but it is only one object in the memory of Java.

To change the file system of the File object, there are numerous methods of "change", such as one for creating a new file (empty), another to change the file name, others giving information about the file, etc. .

For example you can read some file:

  try {
    File fileSD = Environment.getExternalStorageDirectory();

    File file = new File(fileSD.getAbsolutePath(), "file.txt");

    BufferedReader buffered =
        new BufferedReader(
            new InputStreamReader(
                new FileInputStream(file)));

    String texto = buffered.readLine();
    buffered.close();
  }
  catch (Exception ex) {
      Log.e(TAG, "Cannot read the file");
  }

If you want to know the absolute path you can use:

fileSD.getAbsolutePath()

I hope this help you.