dpart dpart - 1 month ago 22
Android Question

getting assets not get the files of assets

I have a project in Android Studio with a lot of libraries. The main project has an assets folder (which contains two folders) and the libraries don't have any assets folders.

I have this code:

public static final Pattern LENGUAJES = Pattern.compile("html-(.+)");

public static List<String> getLenguajesHelp(Context oContext) {
ArrayList<String> oLens = new ArrayList<String>();
AssetManager assetManager = oContext.getAssets();
try {
String[] oFiles = assetManager.list("");
for (int i = 0; i < oFiles.length; i++) {
Log.v("probandoElMatcher", oFiles[i]);
Matcher oMat = LENGUAJES.matcher(oFiles[i]);
if (oMat.find()) {
oLens.add(oMat.group(1));
}
}
} catch (IOException oEx) {
oEx.printStackTrace();
}
return oLens;
}


The
Context
is from the main project (in the assets folder I have a folder named html-es, the idea is that the method matches with that folder) but the method
getAssets.list()
returns a list of files that I don't have in the assets folder, the most of them are
.pak
files. What would be the problem?

Answer

The problem was that i has a lot of flavors, when there are flavors the assets folder must be inside of the main folder (or the specific flavor folder), but i don't know why the get assets returns the .pak files (know returns the .pak files and my files)