What city was the capital of the ancient Israelites?

From the time of King David, it was Jerusalem. Later, the kingdom divided into Israel and Judah. The capital of Judah remained Jerusalem, while the kingdom of Israel made Samaria its capital.