we can create it also from FILE MANAGER in Android, but it takes time. we can create it also by different applications from Google play store. You can make that file within a seconds with that apps and can hide your pictures/gallery from your phone. But keep in mind that if we connect phone with computer or browse it form file manager all files will be shown. you can also use AppLock. AppLock can lock gallery as well as SMS and other apps.
In android phone, for example you don’t want to display pictures that you have received from WhatsApp. so, you have to create a file .nomedia. Android can hide any folder that contain .nomedia file. it hides folder what ever type media that contains.