0

I want to capture an image from camera and save to my own path, not DCIM folder.

I have tried almost all answers of Stackoverflow, but I did not get any solution yet.

Error:

12-26 19:49:39.520: W/System.err(25861): java.lang.NullPointerException 12-26 19:49:39.550: W/System.err(25861): at java.io.File.fixSlashes(File.java:185) 12-26 19:49:39.550: W/System.err(25861): at java.io.File.(File.java:134)

public String finalimagepath = Environment.getExternalStorageDirectory() + "";
private static final int CAMERA_CAPTURE_IMAGE_REQUEST_CODE = 100;    
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

String randomvalue = String.valueOf(System.currentTimeMillis()) + ".png";

File f = new File(finalimagepath, randomvalue);
finalimagefullpath = finalimagepath + "/" + randomvalue;

intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));                                      

startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
sam
  • 2,780
  • 1
  • 17
  • 30
Nick
  • 351
  • 3
  • 7
  • 22
  • possible duplicate of [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – Simon Dec 26 '14 at 14:27
  • I have try lot from all ans but didn't get any solutions so I put – Nick Dec 26 '14 at 14:30
  • Could you provide the complete stacktrace and your required permissions of your manifest? – r0- Dec 26 '14 at 15:36
  • Have you added the `WRITE_EXTERNAL_STORAGE` permission to your manifest file. If you have not, then trying to access external storage could very well be causing a `null` exception. – Willis Dec 26 '14 at 17:59

0 Answers0