Android 在usb上查找文件

Android 在usb上查找文件,android,usb-drive,Android,Usb Drive,我正在检查插入的U盘上是否存在某个文件。代码如下: File usb_dir = Environment.getExternalStorageDirectory(); File myFile = new File(usb_dir+ "/update.apk"); if (myFile.exists()==true) { final Intent promptInstall = new Intent(Intent.ACTION_VIEW).setDataAndType(Uri.parse

我正在检查插入的U盘上是否存在某个文件。代码如下:

File usb_dir = Environment.getExternalStorageDirectory();
File myFile = new File(usb_dir+ "/update.apk");

if (myFile.exists()==true) {
    final Intent promptInstall = new Intent(Intent.ACTION_VIEW).setDataAndType(Uri.parse("file:///mnt/usb_storage/update.apk"), "application/vnd.android.package-archive");
    promptInstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(promptInstall);

    } else if (myFile.exists()==false){
    Toast.makeText(getApplicationContext(), "Not working!", Toast.LENGTH_LONG).show();
}
一切正常,而不是myFile.exists。无论我做什么,它都返回false。知道如何解决吗?

尝试使用:

 String usb_dir = Environment.getExternalStorageDirectory().getAbsolutePath();
 File myFile = new File(usb_dir+ "/update.apk");