标签:
1 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Type | Descrption | Desktop | Android | HTML5 | ios |
Classpath | read-only | Yes | Yes | NO | Yes |
Internal | read-only | Yes | Yes | Yes | Yes |
Local | read-write | Yes | Yes | No | Yes |
External | read-write | Yes | Yes | No | Yes |
Absolute | 绝对路径,尽量少用 | Yes | Yes | No | Yes |
1 boolean isExtAvailable =Gdx.files.isExternalStorageAvailable(); 2 boolean isLocAvailable =Gdx.files.isLocalStorageAvailable();
1 String extRoot =Gdx.files.getExternalStoragePath(); 2 String locRoot =Gdx.files.getLocalStoragePath();
1 FileHandle handle =Gdx.files.internal("data/myfile.txt"); 2 FileHandle handle =Gdx.files.classpath("myfile.txt");//将位于项目目录下 3 FileHandle handle =Gdx.files.external("myfile.txt");//位于用户home目录,windows C:\User linux macos /user/<user>/myfile.txt 4 FileHandle handle =Gdx.files.absolute("/some_dir/subdir/myfile.txt");//获取绝对路径的文件
1 boolean exists =Gdx.files.external("doitexist.txt").exists(); 2 boolean isDirectory =Gdx.files.external("test/").isDirectory();
1 FileHandle[] files =Gdx.files.local("mylocaldir/").list(); 2 for(FileHandle file: files) { 3 // do something interesting here 4 }
1 FileHandle parent =Gdx.files.internal("data/graphics/myimage.png").parent(); 2 FileHandle child =Gdx.files.internal("data/sounds/").child("myaudiofile.mp3");
1 FileHandle file =Gdx.files.internal("myfile.txt"); 2 String text = file.readString(); 3 //获取二进制数据 4 FileHandle file =Gdx.files.internal("myblob.bin"); 5 byte[] bytes = file.readBytes();
1 FileHandle file =Gdx.files.local("myfile.txt"); 2 file.writeString("My god, it‘s full of stars", false); 3 //二进制文件 4 FileHandle file =Gdx.files.local("myblob.bin"); 5 file.writeBytes(newbyte[] { 20, 3, -2, 10 }, false);
1 FileHandle from =Gdx.files.internal("myresource.txt"); 2 from.copyTo(Gdx.files.external("myexternalcopy.txt")); 3 Gdx.files.external("myexternalcopy.txt").rename("mycopy.txt"); 4 Gdx.files.external("mycopy.txt").moveTo(Gdx.files.local("mylocalcopy.txt")); 5 Gdx.files.local("mylocalcopy.txt").delete();
标签:
原文地址:http://www.cnblogs.com/AIThink/p/5848320.html