I am trying to get image from gallery. It is giving me image as bitmap. I want the image in .jpg file so that I can save file name in my database.
I have followed this tutorial :
http://www.theappguruz.com/blog/android-take-photo-camera-gallery-code-sample
gallery image selected code:
@SuppressWarnings("deprecation")
private void onSelectFromGalleryResult(Intent data) {
    Bitmap bm=null;
    if (data != null) {
        try {
            bm = MediaStore.Images.Media.getBitmap(getApplicationContext().getContentResolver(), data.getData());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    Uri selectedImage = data.getData();
    String[] filePath = {MediaStore.Images.Media.DATA};
    Cursor c = getContentResolver().query(selectedImage, filePath, null, null, null);
    c.moveToFirst();
    int columnIndex = c.getColumnIndex(filePath[0]);
    String picturePath = c.getString(columnIndex);
    c.close();
    File file = new File(picturePath);// error line
    mProfileImage = file;
    profile_image.setImageBitmap(bm);
}
I tried this. But I am getting null pointer on file.
Exception :
    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
Also I don't want this newly created file to be saved in external storage. This should be a temporary file. How can I do this?
Thank you..
 
     
    