Home > Mobile >  Android huawei nova7 save photo albums to fail
Android huawei nova7 save photo albums to fail

Time:12-01

If (ContextCompat. CheckSelfPermission (this,
The Manifest. Permission. WRITE_EXTERNAL_STORAGE)!=PackageManager. PERMISSION_GRANTED) {//said unauthorized
//for authorization
ActivityCompat. RequestPermissions (this, new String [] {the Manifest. Permission. WRITE_EXTERNAL_STORAGE}, 1);
}
The String fileName.
The File File;
If (Build) BRAND) equals (" Xiaomi ")) {//millet mobile phone
FileName=Environment. External.getexternalstoragedirectory (.) getPath () + "/DCIM/Camera/" + bitName;
} else {//Meizu, Oppo
FileName=Environment. External.getexternalstoragedirectory (.) getPath () + "/DCIM/" + bitName;
}
The file=new file (fileName);
If (the file. The exists ()) {
file.delete();
}
FileOutputStream out;
Try {
Out=new FileOutputStream (file);
//format to JPEG, camera take pictures as JPEG, PNG format cannot be shown in the photo album
If press (bitmap.com bitmap.com pressFormat. JPEG, 90, (out))
{
Out. The flush ();
out.close();
//insert gallery
MediaStore. Images. Media. InsertImage (enclosing getContentResolver (), the file. The getAbsolutePath (), bitName, null);
}
}
The catch (FileNotFoundException e)
{
e.printStackTrace();
}
The catch (IOException e)
{
e.printStackTrace();
}
//radio, notice sending refresh gallery show
Enclosing sendBroadcast (new Intent (Intent. ACTION_MEDIA_SCANNER_SCAN_FILE, Uri, parse (" file://"+ fileName)));
}


Error in Java. IO. FileNotFoundException:/storage/emulated/0/DCIM/asdf. JPG: open faile EACCES (Permission denied)

CodePudding user response:

I guess it was 6.0 7.0 8.0 for mobile phone memory card address problems, the answer to your search path above 6.0 read a try

CodePudding user response:

reference 1/f, six weeks response:
I guess is 6.0 7.0 8.0 for mobile phone memory card address have problem, the answer to your search path above 6.0 read try


Build. Gradle file is inside the
Android {
CompileSdkVersion 29
BuildToolsVersion "29.0.2
"DefaultConfig {
ApplicationId cn. Cloudbae. "aaa"
MinSdkVersion 15
TargetSdkVersion 29
VersionCode 1
VersionName "1.1.2
"TestInstrumentationRunner "androidx test. The runner. AndroidJUnitRunner"
}
BuildTypes {
Release {
MinifyEnabled false
ProguardFiles getDefaultProguardFile (' proguard - android - optimize. TXT '), 'proguard - rules. Pro'
}
}
}
Don't understand is because of this

CodePudding user response:

DCIM folder which exists on the SD card?

CodePudding user response:

Said, without permission, android 10 to make the changes to your file permissions, see "android 10 new features"
  • Related