0
我創建應用程序的相機功能,我打電話相機與意圖抓拍並保存在外部存儲「下載」文件夾中的文件,但後來我搜索他們,他們是在另一個文件夾「/ storage/emulated/0 /下載/」。模擬外部存儲android
爲什麼android需要2個導演?使用相同的文件,例如我保存的照片。
我正在使用Galaxy Nexus手機。對於Galaxy平板電腦,一切都很好。
public void openCamera(View view) {
try {
int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 1991;
photoName();
String _path = Environment.getExternalStoragePublicDirectory(DOWNLOAD_SERVICE) + "/" + photoFileName;
System.out.println("PATH: "+ _path);
File file = new File(_path);
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
} catch (Exception e) {
}
private String photoName() {
boolean isWhile = true;
int randomId = 0;
int count = 0;
while (isWhile) {
photoFileName = "MobiliSkaita_" + count + ".jpg";
File fileToCheck = new File(Environment.getExternalStoragePublicDirectory(DOWNLOAD_SERVICE) + "/" + photoFileName);
if (fileToCheck.exists()) {
System.out.println("FAILAS YRA: " + randomId);
randomId++;
photoFileName="MobiliSkaita_" + randomId + ".jpg";
} else {
System.out.println("FAILAS NERA: " + randomId);
isWhile = false;
}
count++;
}
return photoFileName;
我使用getExternalStorageDirectory()函數,但文件不會出現在映射的內部存儲「下載」文件夾中。在設備根目錄(外部存儲)中有「下載」文件夾文件。 – Justinas