EACESS错误写入file..ANDROID

时间:2017-01-27 20:09:13

标签: android

确定。谢谢。

这是我管理的......

    String[] perms = {"android.permission. WRITE_EXTERNAL_STORAGE"};

    int permsRequestCode = 200;

   requestPermissions(perms, permsRequestCode);



  public void convertFile(Uri urx)
        throws IOException {

    ContentResolver test = getContentResolver();
    InputStream initialStream =  test.openInputStream(urx);


    byte[] buffer = new byte[initialStream.available()];
    initialStream.read(buffer);

    File xpath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);


    File targetFile = new File(xpath, "/test.mp4");
    OutputStream outStream = new FileOutputStream(targetFile);
    outStream.write(buffer);
    uploadFile(targetFile.getPath());

}

@Override
public void onRequestPermissionsResult(int permsRequestCode, String[] permissions, int[] grantResults){

    switch(permsRequestCode){

        case 200:

            boolean writeAccepted = grantResults[0]== PackageManager.PERMISSION_GRANTED;

            break;

    }

}

尝试编写.mp4文件时出现EACES错误。有没有办法“把它写入记忆”?或者也许你可以解决这个问题。

0 个答案:

没有答案