在使用应用程序路径存储之前请求权限
Request permission before using the app path storage
我的应用程序使用内部\外部存储上的应用程序文件夹读取\写入文件,我通过这段代码获取路径
ContextCompat.getExternalFilesDirs(getAppContext(),null);
我的目标是 SDK 版本 30,最低 SDK 版本 19,如下所示
compileSdkVersion 30
buildToolsVersion '30.0.3'
compileOptions {
encoding = 'utf-8'
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.****.****"
minSdkVersion 19
targetSdkVersion 30
versionCode 82
versionName "4.0.1"
multiDexEnabled true
}
我的问题:使用如下的应用路径存储是否需要申请权限?
private static final String[] PERMS_TAKE_PICTURE = {
INTERNET,
WRITE_EXTERNAL_STORAGE,
ACCESS_NETWORK_STATE,
ACCESS_WIFI_STATE,
READ_EXTERNAL_STORAGE,
RECEIVE_BOOT_COMPLETED,
WAKE_LOCK,
};
ActivityCompat.requestPermissions(this,
PERMS_TAKE_PICTURE,
MY_PERMISSIONS_REQUEST);
非常感谢
Is it necessary to request permission before using the app path storage as below?
对于getExternalFilesDirs()
,您不需要请求任何运行时权限。
我的应用程序使用内部\外部存储上的应用程序文件夹读取\写入文件,我通过这段代码获取路径
ContextCompat.getExternalFilesDirs(getAppContext(),null);
我的目标是 SDK 版本 30,最低 SDK 版本 19,如下所示
compileSdkVersion 30
buildToolsVersion '30.0.3'
compileOptions {
encoding = 'utf-8'
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.****.****"
minSdkVersion 19
targetSdkVersion 30
versionCode 82
versionName "4.0.1"
multiDexEnabled true
}
我的问题:使用如下的应用路径存储是否需要申请权限?
private static final String[] PERMS_TAKE_PICTURE = {
INTERNET,
WRITE_EXTERNAL_STORAGE,
ACCESS_NETWORK_STATE,
ACCESS_WIFI_STATE,
READ_EXTERNAL_STORAGE,
RECEIVE_BOOT_COMPLETED,
WAKE_LOCK,
};
ActivityCompat.requestPermissions(this,
PERMS_TAKE_PICTURE,
MY_PERMISSIONS_REQUEST);
非常感谢
Is it necessary to request permission before using the app path storage as below?
对于getExternalFilesDirs()
,您不需要请求任何运行时权限。