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....

Blizzer
  • 260
  • 4
  • 22
prasad.gai
  • 2,977
  • 10
  • 58
  • 93
  • 1
    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? – Squonk Jul 14 '12 at 07:36
  • http://stackoverflow.com/questions/7887078/android-saving-file-to-external-storage/7887114#7887114 – NagarjunaReddy Jul 14 '12 at 07:18
  • have a look at this issue http://stackoverflow.com/questions/10370188/issue-with-reading-file-from-internal-memory http://stackoverflow.com/questions/10378895/android-download-doc-pdf-from-the-internet-and-save-to-internal-memory http://stackoverflow.com/questions/7674784/delete-file-in-internal-memory-from-android-device http://stackoverflow.com/questions/9306155/writing-reading-files-to-from-android-phones-internal-memory I hope any query from this would be helpful to you – Aamirkhan Jul 14 '12 at 07:27

1 Answers1

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);
}
Blizzer
  • 260
  • 4
  • 22
GOLDEE
  • 2,318
  • 3
  • 25
  • 49