检查文件,始终返回true

时间:2013-10-06 19:14:09

标签: java android

我尝试了下面的代码,如果我重命名音乐文件Musik_stk100.mp3,if仍然会返回true?

我做错了什么?

String filepath = "file:///mnt/sdcard/data/musikapp/";
final File musicfile = new File(filepath  + "/" + "Musik_stk100.mp3");
final ImageView imagetrue = (ImageView) findViewById(R.id.imagetrue);
final ImageView imagefalse = (ImageView) findViewById(R.id.imagefalse);

    if (musicfile.exists()){
        imagetrue .setVisibility(View.VISIBLE);
        imagefalse .setVisibility(View.GONE);
    } else {
        imagefalse .setVisibility(View.VISIBLE);
        imagetrue .setVisibility(View.GONE);
    }

String filepath = (Environment.getExternalStorageDirectory() + "/data/musikapp/");
final File musicfile = new File(filepath  + "Musik_stk100.mp3");
final ImageView imagetrue = (ImageView) findViewById(R.id.imagetrue);
final ImageView imagefalse = (ImageView) findViewById(R.id.imagefalse);

    if (musicfile.exists()){
        imagetrue .setVisibility(View.VISIBLE);
        imagefalse .setVisibility(View.GONE);
    } else {
        imagefalse .setVisibility(View.VISIBLE);
        imagetrue .setVisibility(View.GONE);
    }

0 个答案:

没有答案