Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Android version greater than 23 #7

@pgAlves2

Description

@pgAlves2

If android version is greater than 23(6.0) is necessary order the WRITE_EXTERNAL_STORAGE permission for create files, cuz this permission among others must be requested in run time (only version >=23).

Example method:

public boolean isStoragePermissionGranted() { if (Build.VERSION.SDK_INT >= 23) { if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { return true; } else { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); return false; } } else { return true; } }

Callback :

@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if(grantResults[0]== PackageManager.PERMISSION_GRANTED){ //do something } }

ty for your code!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions