0

I'm trying to allow user to rename file name, after taking picture, but I need to allow renaming to it right after saving the picture. So I want the name of the image to be shown in an EditText.

My saving code:

Intent takePictureFromCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri mUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "/Folder/cam_"+ String.valueOf(System.currentTimeMillis()) + ".jpg"));
takePictureFromCameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mUri);
startActivityForResult(takePictureFromCameraIntent,1111);

String oriFileName = mUri.getPath();

My plan is : get the path with the name (oriFileName), then remove the front leave only the file name(cam_ ). But I have no idea on how to do so.

Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
starvi
  • 519
  • 4
  • 15
  • 29

1 Answers1

3

here you go:

String oriFileName = mUri.getPath();
oriFileName = oriFileName.substring(0, oriFileName.lastIndexOf("_"));
waqaslam
  • 67,549
  • 16
  • 165
  • 178
  • thks. even though the answer you provided is wrong, but it does help. – starvi Jan 24 '12 at 14:12
  • well because the code you gave does not give what i want. the text that i want it to return should start from cam_ and not from 0. the code that i use is : fileName = fileName.substring(fileName.lastIndexOf("cam_"), fileName.length()); – starvi Jan 28 '12 at 08:33