我有一个问题:我无法读取从连接到设备的USB存储器中获取的文件。当我打开Linux控制台时,我看到文件位于/mnt/media_rw/[HEX_ID]
。我已经尝试过了:
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard,"key.txt");
但是我无法读取此文件。
答案 0 :(得分:0)
检查是否:
Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED_READ_ONLY && Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED
如果可以,请使用以下方法:
File file = new File(getExternalFilesDir(Environment.getExternalStorageDirectory()),"key.txt");