2

I want to be able to access all of the files in the raw folder of the resources folder in my Android application package. I have created a function that gets an array of files from a folder in the external storage directory, but I want to do the same thing for the files in the raw folder of the resources folder. I have looked at different suggestions, but most people seem to want to access a specific file. I only want to access the folder and then create an array of files in that folder. Please could anyone help me with this to find a solution. Thanks in advance.

Here is the code for my other function that I have created:

public static List<String> getListOfSavedFileNames()
{
    File folder = new File(Environment.getExternalStorageDirectory() + "/XML/");
    List<String> listOfFileNames = new ArrayList<String>();
    if(folder.exists())
    {
        File[] listOfFiles = folder.listFiles();
        for(File f : listOfFiles)
        {
            String fileName = f.getName();
            String finalFileName = FileExtentionFunctions.removeExtention(fileName);

            listOfFileNames.add(finalFileName);
        }
    }
    else
    {

    }
    return listOfFileNames;
}
James Meade
  • 1,147
  • 5
  • 22
  • 46

1 Answers1

2

There are no files. Raw resources are resources, not files.

You are welcome to:

  • Have a "table of contents" resource that lists the other ones, as a <string-array> or an XML resource or something

  • Use reflection to iterate over the R.raw values

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    So you mean that they are actually like references to the files as opposed to the files themselves? How can I get the file names of all of the files in that folder then? – James Meade Dec 05 '13 at 16:28
  • @JamesMeade: "So you mean that they are actually like references to the files as opposed to the files themselves?" -- they are byte arrays packaged inside the APK file. "How can I get the file names of all of the files in that folder then?" -- I covered this in my answer. – CommonsWare Dec 05 '13 at 17:02
  • I used reflection and it worked. Thank you very much! – James Meade Dec 05 '13 at 17:02