Android添加sd卡权限
1.在AndroidManifest.xml中添加
<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" /><uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />
2.再在想引用的地方添加verifyPermission函数
public void verifyPermission(Context context) {int permission = ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE);if (permission != PackageManager.PERMISSION_GRANTED) {// We don\'t have permission so prompt the userActivityCompat.requestPermissions(MainActivity.this,PERMISSIONS_STORAGE,REQUEST_EXTERNAL_STORAGE);}}
3.在onCreate函数中添加
verifyPermission(MainActivity.this)