java.lang.IllegalStateException: Can’t change tag of fragment PageFragment{42ef29a8 #14 id=0x7f060052 android:switcher:2131099730:22}: was android:switcher:2131099730:22 now android:switcher:2131099730:17
后面在SUN的官方论坛上看到有人提到这个问题“works on windows, don’t work on linux”,后面有人回复说是“file systems”不一样。究竟怎么不一样呢?还是没有想出来…
后面在一个论坛里面发现了某人关于这个问题的阐述:
In the Unix’esque O/S’s you cannot renameTo() across file systems. This behavior is different than the Unix “mv” command. When crossing file systems mv does a copy and delete which is what you’ll have to do if this is the case.
The same thing would happen on Windows if you tried to renameTo a different drive, i.e. C: -> D:
终于明白咯。
做个实验:
1 2 3 4 5 6 7 8 9 10 11 12 13
File sourceFile = new File("c:/test.txt"); File targetFile1 = new File("e:/test.txt"); File targetFile2 = new File("d:/test.txt"); System.out.println("source file is exist? " + sourceFile.exists() + ", source file => " + sourceFile); System.out.println(targetFile1 + " is exist? " + targetFile1.exists()); System.out.println("rename to " + targetFile1 + " => " + sourceFile.renameTo(targetFile1)); System.out.println("source file is exist? " + sourceFile.exists() + ", source file => " + sourceFile); System.out.println(targetFile2 + " is exist? " + targetFile2.exists()); System.out.println("rename to " + targetFile2 + " => " + sourceFile.renameTo(targetFile2));
结果:
source file is exist? true, source file => c:\test.txt
e:\test.txt is exist? false
rename to e:\test.txt => false
source file is exist? true, source file => c:\test.txt
d:\test.txt is exist? false
rename to d:\test.txt => true