The only method that really works for me is to have other constructive things I genuinely want to do. It's easier to avoid picking up the phone or getting on the computer (breaking the habit) if I'm thinking about X instead. That can be a hobby, a project, or even better a friend, relative, child. I don't want to sound like I'm saying, "just do this one trick." I know it's not easy and everyone is different.
The children's book Frog and Toad Together has a story about willpower called "Cookies". It sums up my experience pretty well. If you do write a book about what works for you, consider making it a children's book: I've gotten more comfort and understanding from those than anything else.