``` File file1 = new File(Environment.getExternalStorageDirectory() + "/test.txt"); ```
然后,在特定的JB设备上,`file1.getCanonicalPath()`返回:`"/storage/emulated/0/test.txt"`。
问题在于,当其他应用程序通过意图(Intent)发送文件路径时,它们发送的路径通常看起来像:`"/mnt/sdcard/test.txt"`。
有没有一种聪明的策略来区分这两个路径?也许我应该以不同的方式实例化我的文件?
编辑:
问题是,这两个文件的规范路径不相等。对于以下内容,`cp1=="mnt/sdcard/test/txt"`和`cp2=="/storage/emulated/0/text/txt"`:
File file1 = new File("/mnt/sdcard/test.txt");
File file2 = new File("/storage/emulated/0/test.txt");
String cp1 = file1.getCanonicalPath();
String cp2 = file2.getCanonicalPath();
Intent
发送给您时是如何准备的,何时发送的? - Deepak Bala