简体   繁体   English

LibGDX-在Gdx.audio.newMusic()中分配后如何从ANDROID设备中删除文件;

[英]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...
    }
}

  • Aim - i need to delete the file after assignment(in some way) 目的 -我需要在分配后删除文件(以某种方式)

  • Question - how can i delete the file after assigning it to Gdx.audio.newMusic() ? 问题 -将文件分配给Gdx.audio.newMusic()后如何删除文件? Eventually if i had to disconnect it how should i do? 最终,如果我必须断开连接,该怎么办?

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.

相关问题 libGDX无法从Gdx.files.internal读取文件 - libGDX Cannot read file from Gdx.files.internal Android上的Libgdx无法检测GDX字体 - Libgdx on android not able to detect GDX fonts Libgdx从Gdx.files.external()加载纹理显示为黑色矩形 - Libgdx load texture from Gdx.files.external() showing as black rectangles 如何在Android设备上查找和删除媒体文件 - How to find and delete media files on device in Android LibGDX And​​roid Gdx.app.exit() 不起作用,如何以另一种方式关闭应用程序? - LibGDX Android Gdx.app.exit() doesnt work, how to close app in another way? 如何从Android 4.0以上的Android设备(如Whatsapp)获取音频文件? - How can I fetch the Audio files from Android Device above Android 4.0 like Whatsapp? 如何以编程方式从设备检索文件或音频文件? - How do I retrieve files or audio files programmatically from the device? libGDX:Gdx.net.openURI后GoogleApiClient断开连接 - libGDX: GoogleApiClient disconnected after Gdx.net.openURI 如何在 android 中将应用音频文件与 whatsapp 音频文件分开 - How to separate app audio files from whatsapp audio files in android libGDX可解锁产品管理和gdx-pay \\ Native Android \\ IOS付款 - libGDX unlockables management and gdx-pay\Native Android\IOS payments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM