I want to that a program / software like facebook/gmail/ or any game will survive after factory reset with its configuration as before reset means email id password automatically configured after reset. any suggestion please?
Preserving the application itself (APK) can be easily achieved (with root access) by dropping the .apk in /system/app, but the configurations are a bit trickier to keep.
Factory resets generally do a wipe of /data, which also contains all the configs/gamesaves/etc that all apps installed have, so you might have to use a seperate backup app (I recommend Titanium Backup) for that.
As aureljared already pointed out, a factory-rest wipes the
/data permission, so you cannot simply "exclude" and app and its data from being "removed". However, you can backup it beforehand, and restore it afterwards.
Easiest way (not requiring root) is utilizing
adb backup for this. It will require the ADB tools installed on your computer1, and usb-debugging turned on on your device, but that's it. Then you can either deal with it directly from your computer (with the device attached via USB), or use a tool like Helium - App Sync and Backup directly on your device (after initializing it via your computer, if your device is not rooted) to backup and restore all or selected apps.2