James Meade
James Meade

Reputation: 1169

Access resources folder and list of files in raw folder in package in Android

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;
}

Upvotes: 2

Views: 1451

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006799

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

Upvotes: 2

Related Questions