suchen

Heim  >  Fragen und Antworten  >  Hauptteil

Android 5.1.1删除USB U盘文件

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

1

2

3

4

5

6

7

8

9

10

<code>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)));</code>

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

PHP中文网PHP中文网2889 Tage vor644

Antworte allen(1)Ich werde antworten

  • ringa_lee

    ringa_lee2017-04-18 09:09:08

    从Android 4.4起Google引入了一套新的Api,即Storage Access Framework (SAF),存储访问框架,可以用这个来读写SD卡上的内容。

    附:
    stackoverflo相关讨论帖

    Antwort
    0
  • StornierenAntwort