Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
591 views
in Technique[技术] by (71.8m points)

image - Android device specific camera path issue

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.

That is:

  • Nexus-One stores its camera files into a folder named Camera (/sdcard/DCIM/Camera).

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

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

  • 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?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

for API level > 7 use getExternalStoragePublicDirectory (DIRECTORY_PICTURES).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...