Android设备特定的相机路径问题 [英] Android device specific camera path issue

查看:17
本文介绍了Android设备特定的相机路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我的问题与 this question这个.但是我仍然有一些问题,所以不要试图关闭或否决我的问题朋友.请完整地回答问题.

I know that my question is a duplicate of this question and this one. But still I have some problems, so don't try to close or downvote my question friends. Please go through the question fully.

在我的应用程序中,我想将图像存储到与设备本机相机存储它们的位置相同的文件夹中.根据我的研究,我发现每个设备都将图像存储到不同的名称和不同的文件夹中.

In my app I want to store Images into the same folder as where the device native Camera stores them. As per my research, I have found out that each device stores the Images into a different name and in different folder.

即:

  • Nexus-One 将其相机文件存储到名为 Camera (/sdcard/DCIM/Camera) 的文件夹中.

所有 HTC 设备都将其相机文件存储到名为 100MEDIA (/sdcard/DCIM/100MEDIA) 的文件夹中.

All HTC devices store their camera files into a folder named 100MEDIA (/sdcard/DCIM/100MEDIA).

Sony Xperia x10 将其相机文件存储到名为 100ANDRO (/sdcard/DCIM/100ANDRO) 的文件夹中.

Sony Xperia x10 stores its camera files into a folder named 100ANDRO (/sdcard/DCIM/100ANDRO).

Motorola MilesStone 将其相机文件存储到名为 Camera (/sdcard/DCIM/Camera) 的文件夹中.

Motorola MilesStone stores its camera files into a folder named Camera (/sdcard/DCIM/Camera).

所以我想知道是否可以通过编程方式获取此路径,以便我可以将从我的应用获取的图像存储到同一位置?

So I wanted to know if it's programmatically possible to get this path so that I can store the images taken from my app to the same location?

当我在谷歌上搜索时,我发现最好创建一个自己的外部文件夹,这样我就可以使用我指定的名称将图像存储在该路径中.之后,在 API 版本 3(Android 1.5)的 HTC 设备中,我发现只有文件夹被创建,但图像以自己的名称保存在默认位置.

When I was googling I found out that it's better to create an external folder of my own so that I can store the images in that path with the name I am specifying. After that also in HTC device of API version 3 (Android 1.5) I found out that only the folder is getting created but the image gets saved in its default place with a name of its own.

如何解决这个问题?是否无法找到为每个设备保存的图像的特定路径和名称?请朋友们帮帮我.

How to solve this issue? Is it not possible to find the specific path and name of the image that gets saved for each device? Please help me friends.

推荐答案

如果API级别低于7,使用getExternalStorageDirectory(),然后附加/Pictures获取照片存储路径.

Use getExternalStorageDirectory() if API level is below 7 and then append /Pictures to get the path of Photos storage.

对于 API 级别 > 7,请使用 getExternalStoragePublicDirectory (DIRECTORY_PICTURES).

for API level > 7 use getExternalStoragePublicDirectory (DIRECTORY_PICTURES).

这篇关于Android设备特定的相机路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆