问题描述:

I'm working on an android project for school. I want it to be very open closed so i thought of a way of checking if there are images till there aren't anymore. But it doesn't work very well.

My code needs to check if the file exist and continue to the next until he can't find anymore.

this is what i have right now:

 File file = null;

try {

for (int i = 1; 0 < i; i++) {

String path = "R.drawable.shirt" + i;

file = new File(path);

if (file.exists()) {

Log.d("Kleding", "number: "+i);

int id = i;

int prijs = i * 20;

int gekocht = 0;

Kleding k = new Kleding(id, prijs, gekocht);

this.insertKledingInDatabase(k);

} else {

Log.d("Kleding", "nothing"+i);

break;

}

}

} catch (Exception e) {

}

相关阅读:
Top