Open an image in gallery using file path

android, eclipse, java

Solution

Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(new File(filename)), "image/*");
            startActivity(intent);

Use this code and tell me

Problem

i have an image file path stored in my database. Now using it i want to open images from SD Card in my gallery. How can i do that. I have seen methods from Uri and using this method but i am getting error ``` File file = new File(filename); Uri uri = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.setType("image/*"); startActivity(intent); /** replace with your own uri */ ``` How to fix it, ``` 04-20 08:42:23.516: E/AndroidRuntime(16815): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/My%20App/image_umxto_1.jpg } ``` best regards

Original source