I check mp3 file numbers and numbers for an item in android

I am very tired of using the encoding for the mp3 file and show number for the item, but item shows the numbers of all the files and folders for the item. this code

File[]dirs = f.listFiles();
        this.setTitle(""+f.getName());//File show in Action Bar
        List<Item>dir = new ArrayList<Item>();
        List<Item>fls = new ArrayList<Item>();
        try{
            for(File ff: dirs)
            {
                Date lastModDate = new Date(ff.lastModified());
                DateFormat formater = DateFormat.getDateTimeInstance();
                String date_modify = formater.format(lastModDate);
                if(ff.isDirectory()) {
                        File[] fbuf = ff.listFiles();
                        int buf = 0;
                        if (fbuf != null) {
                            buf = fbuf.length;
                        } else buf = 0;
                        String num_item = String.valueOf(buf);
                        if (buf == 0) num_item = num_item + " item";
                        else num_item = num_item + " items";
//String formated = lastModDate.toString();
                        dir.add(new
                                Item(ff.getName(), num_item, null, ff.getAbsolutePath(), "directory_icon"));
                    }

`

+4
source share

Source: https://habr.com/ru/post/1599631/


All Articles