Reputation: 2139
One activity of my Android application needs to show all the pictures from the phone including sd-card, camera pictures, downloads, etc. How can I perform this with the code? Whether through Intent or some other possible ways? (for instance in google+ application it shows all the pictures from the phone).
Upvotes: 3
Views: 8409
Reputation: 9385
Do you just want to open just the stock Android gallery application?
If you don't, you can always use this MediaStore class. It has all the info you need. http://developer.android.com/reference/android/provider/MediaStore.html
Upvotes: 0
Reputation: 89626
The best way to do this is by using the MediaStore.Images
content provider. This will show all the images that appear in the Gallery app. However, it will not show hidden images, or images in folders that contain a .nomedia
file. If you want to show those as well, you'll have to recursively scan the filesystem yourself (see File
for that).
Upvotes: 1
Reputation: 4245
You need to query the content database using the content resolver
String[] mProjection = {MediaStore.Images.Media._ID,
MediaStore.Images.Media.DATA};
mCursor = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
mProjection,
null,
null,
MediaStore.Images.Media.DEFAULT_SORT_ORDER);
Using the mCursor above you can get the path to the images present on your external storage device.
You will probably require a GridView
and the adapter to the GridView
can use the cursor to get the images one by one.
Upvotes: 4