2

As the title says, I want to get the name of the file which is just taken from camera. I have a full path of the image such as like this sdcard\image.jpg. So how can I get image.jpg name in android? Any sample code would be helpful.

Update

OR How can I simply get the name of the photo which is just taken from the camera? It doesnt matter if I know the path of the image.

Om3ga
  • 30,465
  • 43
  • 141
  • 221

1 Answers1

1
    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
    startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);

In onActivityResult() method:

                Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); 
                path=getLastImagePath();      
                int dotposition= path.lastIndexOf("/");
                imageName = path.substring(dotposition + 1, path.length());

This will give you the path of the last image in "path" variable and image name in "imageName" variable.

Yogesh Somani
  • 2,624
  • 3
  • 21
  • 34