// get asset mp3 file to arraylist
// init ArrayList<String> arrayList;
private void getAssetFiles() {
arrayList = new ArrayList<>();
try {
AssetManager assetFiles = getAssets();
files = assetFiles.list("musika");
InputStream in = null;
OutputStream out = null;
for (int i = 0; i < files.length; i++) {
if (files[i].toString().equalsIgnoreCase("images")
|| files[i].equalsIgnoreCase("js")) {
} else {
if(files[i].contains("mp3")){
arrayList.add(files[i]);
}
}
}
files = new String[arrayList.size()];
items = new String[arrayList.size()];
for(int i=0; i<arrayList.size();i++) {
files[i] = arrayList.get(i).toString();
items[i] = arrayList.get(i).toString().replace(".mp3","").replace(".wav","").replace("_"," ");
items[i] = items[i].toString().substring(0,1).toUpperCase() +
items[i].toString().substring(1,items[i].length());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
No comments:
Post a Comment