How to detect camera is attached or removed using flash

I am using camera object to detect whether camera is attached or not and also to find if camera is attached or remove after some time.now I am facing problem that initially camera is unplugged now the status is no camera found.after that I plugged the camera now it show camera found but if again I unplugged the camera then it keep on showing camera is available.I am calling the camera object in timer.The code is as mentioned below