当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Checking if image exist till there aren't anymore

问题描述:

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) {

}

分享给朋友:
您可能感兴趣的文章:
随机阅读: