[英]LibGDX - how delete files from ANDROID device after the assignment in Gdx.audio.newMusic();
Yes, i can't delete this file from the Android device just because it was assigned to Gdx.audio.newMusic() 是的,我不能仅因为已将其分配给Gdx.audio.newMusic()而从Android设备中 删除该文件
If i want to delete the file, generally i can do it safely, but if i assign it via Gdx.audio.newMusic() then i can no longer delete it. 如果我想删除文件,通常我可以安全地完成它,但是如果我通过Gdx.audio.newMusic()分配它,那么我将无法再删除它。
(this is the piece of code working 100%) (这是100%有效的代码)
public class TEST_Android
{
public static Music M = null;
// *** Test: Delete-file WITHOUT assignment ***
//
public void TEST_A()
{
Gdx.files.local("PurpleRain.ogg").delete(); // work 100%
//
// --- i've checked the file on Android mobile and is NOT present
// --- has been deleted correctly
}
// *** Test: Delete-file AFTER assignment ***
//
public void TEST_B()
{
M = Gdx.audio.newMusic(Gdx.files.local("PurpleRain.ogg")); // work 100%
M.play(); // work 100%
M.stop(); // work 100%
M.delete(); // doesn't work!
//
// --- i've checked the file on Android mobile and is ever present!
// --- not deleted...
}
}
Could you help me please? 请问你能帮帮我吗? Thank you all
谢谢你们
The Music class does not have a delete method so obviously you can not call that. Music类没有Delete方法,因此显然您无法调用该方法。 You can try calling its
#dispose
Method and try deleting it via Gdx.files.local("PurpleRain.ogg").delete();
您可以尝试调用其
#dispose
方法,然后尝试通过Gdx.files.local("PurpleRain.ogg").delete();
which may, or may not work. 这可能会,也可能不会。
This seems like a strange thing to do however, are you sure you need to delete the file? 但是,这似乎很奇怪,确定要删除该文件吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.