开发者

How to delete a file that exists in the SD card in Android?

开发者 https://www.devze.com 2023-03-23 01:44 出处:网络
I tried these codes to delete a wav file in the sd card from android File file = new File(\"/sdcard/AutoInsurance_Toolkit/AudioRecorder/1311531953080开发者_StackOverflow中文版.wav\");

I tried these codes to delete a wav file in the sd card from android

File file = new File("/sdcard/AutoInsurance_Toolkit/AudioRecorder/1311531953080开发者_StackOverflow中文版.wav");

boolean deleted = file.delete();

and also in the manifest used the permission

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">

Please tell me am I missing something here because each time the code gets executed successfully but not deleting the content in SD card?


Your code will work assuming you have the WRITE_EXTERNAL permission, the path is correct and the file permission is WORLD_WRITABLE. I'm betting the file was not created as world writable so unless your software created the file you won't be able to delete it.

0

精彩评论

暂无评论...
验证码 换一张
取 消