[英]emulated external storage android
I creating apps with camera function, I call camera with intent snap the shot and saving files in external storage "download" folder, but then I search them they are in another folder "/storage/emulated/0/download/". 我创建具有摄像头功能的应用程序,并有意将摄像头称为快照并将文件保存在外部存储的“下载”文件夹中,但是随后我搜索它们在另一个文件夹“ / storage / emulated / 0 / download /”中。
Why android needs 2 directors? 为什么Android需要2个导演? With same files excep my saved photos.
使用相同的文件可以保存我的照片。
I'm using Galaxy Nexus phone. 我正在使用Galaxy Nexus手机。 For Galaxy tablet everything is allright.
对于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;
From http://developer.android.com/guide/topics/data/data-storage.html#filesExternal , some devices use different directories for external storage. 在http://developer.android.com/guide/topics/data/data-storage.html#filesExternal中 ,某些设备使用不同的目录进行外部存储。
You should try (API >= 8): 您应该尝试(API> = 8):
Context.getExternalFilesDir();
or (API < 8) 或(API <8)
Context.getExternalStorageDirectory();
to get the external storage directory on the current device (assuming it is mounted). 获取当前设备上的外部存储目录(假设已安装)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.