0
         File myFile = new File(PathFileToRead);

            FileInputStream fIn = new FileInputStream(myFile);
            BufferedReader myReader = new BufferedReader(
                    new InputStreamReader(fIn));

i used this code to read a file , but probably, with the last system update , i have not permission to do that. can you help me?

thanks in advance

AndreaDJt
  • 11
  • 4

4 Answers4

0

you need to implement https://developer.android.com/training/permissions/requesting.html as per new Marshmallow update in android

Nilay Dani
  • 896
  • 6
  • 24
0

add read permission into your manifest

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

If your are on Marshmallow you need to use runtime permission request

thunder413
  • 585
  • 3
  • 10
0

Checkout in Manifest file if you have added following line -

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

Additionally also check if you have added Marshmallow's runtime check for permission. For detail, on how to use it, you can check it over here.

Community
  • 1
  • 1
Jimit Patel
  • 4,265
  • 2
  • 34
  • 58
0

i added in my MainActivity this code below, and i solve it. Thank a lot

ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);

public void onRequestPermissionsResult(int requestCode,
                                       String permissions[], int[] grantResults) {
    switch (requestCode) {
        case 1: {
            // If request is cancelled, the result arrays are empty.

            if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {


        /*HERE PERMISSION IS ALLOWED.
        *
        * YOU SHOULD CODE HERE*/


            } else {

                Toast.makeText(MainActivity.this, "Permission deny to read your External storage", Toast.LENGTH_SHORT).show();
            }
            return;
        }

        // other 'case' lines to check for other
        // permissions this app might request
    }
}
AndreaDJt
  • 11
  • 4