Read My Whole Code. It is working perfectly on every Phone except Marshmallow and Lollipop. In Marshmallow and Lollipop p
It is working perfectly on every Phone except Marshmallow and Lollipop
No, it is not. It will fail on lots of Android versions, when the user chooses a well-written camera app to handle your ACTION_IMAGE_CAPTURE request.
Your problem lies here:
if (data.getData()!=null){
picturePath=getPath(column_Name,data.getData());}
else {
//My app Crashes here because in Marshmallow data.getData() is always null.
}
There are at least two flaws here.
The big one is assuming that you get a Uri back from ACTION_IMAGE_CAPTURE. That is not documented, and camera apps do not need to return a Uri. In particular, in your structure, you will only get a thumbnail back, via getExtra("data"). If you want a full-size image, use EXTRA_OUTPUT on your Intent, in which case you know where the image is being stored — it is wherever you are indicating in EXTRA_OUTPUT.
The other one is that you assume that the Uri that you get back is from the MediaStore or otherwise has a MediaStore.Video.Media.DATA column. Not only do camera apps not have to return a Uri, but there is no requirement that the Uri is from the MediaStore or have such a column.