King David’s Fast

When King David fasted what was his motive?