Can I find the file with the desired extension in the assets folder?

I have an app with a randomly generated assets folder. In this resource folder, every time my application opens, I have to open a file with the extension ".jet". The problem is that the file will have different random names every time the application is opened.

So. How can I find the first file with a folder with a ".jet" extension?

I cannot find information about this on google

thank

+3


source to share


2 answers


The only way is to find extensions:



AssetManager am = getAssets();
String fileList[] = am.list("");

for (String fileName : fileList) {
      if (fileName.endsWith(".jet") {

       }
}

      

+5


source


let me know if below code works for you?

Arrays.asList(getResources().getAssets().list("")).contains(".jet");

      



it will return an array with names containing .jet, or you can also use endsWith with filenames

0


source







All Articles