how to get all images and photos from my android device not from sdcard?
Asked Answered
D

1

7

i would like to get all images/photos/wallpapers from my android device with image saved path.

I have implemented code for collect the images from sdcard as follows:

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);

from the above code i can able to retrive the images from sdcard only.But if the images are available in device phone memory then how can i retrive the images/photos/wallpapers? If i use INTERNAL_CONTENT_URI it is not returning wallapers info other images information

please any body help me....

Dicrotic answered 14/7, 2012 at 7:9 Comment(3)
#7887578Interfluent
have a look at this issue #10370688 #10379395 #7675284 #9306655 I hope any query from this would be helpful to youToady
Are you sure there are 'wallpaper' images (or any other images) stored in the internal memory that are accessible by your app? If you use INTERNAL_CONTENt_URI does it return anything at all?Chrono
P
0

Try this answer this will work:

public static final int GALLERY_CODE = 322;

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(
    intent,
    "Select Picture"),
    GALLERY_CODE);


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//Assinging on corresponding import
super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == GALLERY_CODE && resultCode == RESULT_OK) {
        Uri selectedImageUri = data.getData();
        selectedImagePath = getPath(selectedImageUri);

        try {

            //add logic for coping file

        } catch (Exception e) {
        }
    }
}

public String getPath(Uri uri) {
    String[] projection = { MediaStore.Images.Media.DATA };
    Cursor cursor = managedQuery(uri, projection, null, null, null);

    int column_index = cursor
        .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);

    cursor.moveToFirst();
    return cursor.getString(column_index);
}
Preconcert answered 16/1, 2013 at 12:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.