If you want help you need to specify what the code is supposed to do and what is the problem, together with potential error logs.
Throwing a piece of code and asking what is wrong with this won't get you any answer. I also wish people would stop saying "not working" - this is not helpful at all. Describe what is happening, in which way it is not working.