Yes, i can't delete this file from the Android device just because it was assigned to Gdx.audio.newMusic()
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.
(this is the piece of code working 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. You can try calling its #dispose
Method and try deleting it via 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?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.