I am making an app to click pics and save that images in app folder.I want my images to be private to application only and not viewable in gallery. But with the code I have writ
You should not be using Environment.getExternalStoragePublicDirectory() to get the directory for your images. As the method's name implies, it will return a public directory.
To get your app's private data directory, you can call Context.getFilesDir().
See here for a guide that provides more information about writing app-private files.