I am using an custom view and in that i am using an canvas in which a user can draw anything and after that i want to save that image in sd card bt was not able to do that.
A bit late answer, but still...
Not sure which is line 238, but probably the reason is here:
String imgSaved = MediaStore.Images.Media.insertImage( getContentResolver(), drawView.getDrawingCache(), UUID.randomUUID().toString()+".png", "drawing");
Since the method is within a click listener getContentResolver may be returning a Resolver different from the one for the application. Either save a private reference to the content resolver, or you could try replacing getContentResolver with MainActivity.this.getContentResolver() :
String imgSaved = MediaStore.Images.Media.insertImage( MainActivity.this.getContentResolver(), drawView.getDrawingCache(), UUID.randomUUID().toString() + ".png", "drawing");
Alternatively, it might be a permissioning problem. Make sure in the manifest you have:
One final note, the result of insertImage is an URI, imgSaved is not the best name for that variable :)