-1

I am trying to copy some files from remotely connected pc to my Android Device's SDCard but it is showing an error "No write permission". while i transfer same files to internal storage, it transferred successfully.

I have already included these permission:

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

My Android Device is running on Android Version 6.0.1

Absar Alam
  • 102
  • 2
  • 9
  • 2
    Possible duplicate of [Android runtime permissions- how to implement](https://stackoverflow.com/questions/35163953/android-runtime-permissions-how-to-implement) – Suraj Rao Jul 10 '17 at 12:26
  • Please edit your question and provide a [mcve]. This would include the full Java stack trace for your crash, plus the Java code that is referenced in that stack trace. – CommonsWare Jul 10 '17 at 12:43

1 Answers1

1

Use Run time permission for Android Version 6.0.0 and more Click here for more information

    public boolean isStoragePermissionGranted() {
                if (Build.VERSION.SDK_INT >= 23) {
                    if (checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)
                            == PackageManager.PERMISSION_GRANTED) {
                        Log.v("======>", "Permission is granted");
                        return true;
                    } else {

                        Log.v("======>", "Permission is revoked");
    //1 is request code
                        ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
                        return false;
                    }
                } else { //permission is automatically granted on sdk<23 upon installation
                    Log.v("======>", "Permission is granted");
                    return true;
                }
            }

            @Override
            public void onRequestPermissionsResult(int requestCode, String[] permissions,
                                                   int[] grantResults) {
                super.onRequestPermissionsResult(requestCode, permissions, grantResults);
                switch (requestCode) {
    //1 is request code
                    case 1: {
                        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                            Log.v("======>", "Permission: " + permissions[0] + "was " + grantResults[0]);
                            openFileAttachDialog();
                        }
                    return;
                    }
                }
Anil
  • 1,605
  • 1
  • 14
  • 24