Android 5.1.1删除USB U盘文件
PHP中文网
PHP中文网 2017-04-18 09:07:08
0
1
554

一直获取不到写的权限,只有读的权限。
代码如下:

File f=new File(homedir,file);    
        f.setExecutable(true, false);
        f.setReadable(true, false);
        f.setWritable(true, false);
        if(f.canWrite())
            Log.i("rrrrrrr","file can write");
        else
            Log.i("rrrrrrr","file cannot write");
        f.delete();
        this.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(f)));

设备为Android 5.1.1电视,用es文件浏览器可以删除U盘文件,但是需要确认对话框,现尚无法查明该机制

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
左手右手慢动作

Starting from Android 4.4, Google has introduced a new set of APIs, namely Storage Access Framework (SAF), a storage access framework that can be used to read and write content on the SD card.

Attachment:
stackoverflo related discussion thread

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template