android - How to count items in a directory? -


i need count number of items in directory in android, example; how many files there in "layout" directory?

if count array do

(int = 0; < array.lenght; i++){     count++; } 

how change "array.lenght" suitable directory? i'm doing because want create x-number of views depending on amount of items in drawable. if add new ".xml" in drawable directory, app generate view item automatically because of for-loop.

the android resources identified constants in r class generated aapt. reflection can count number of fields (e.g. drawables):

int getdrawablescount() {     return r.drawable.class.getfields().length; } 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -