President Barack Obama said on Sunday that the U.S. government has to improve its cyber security practices for the modern age of smart phones and other technology, saying that hackers had targeted the White House.

U.S. President Barack Obama answers a reporter's questions after meeting with Spain's acting Prime Minister Mariano Rajoy at the Palacio de la Moncloa in Madrid, Spain July 10, 2016. REUTERS/Jonathan Ernst REUTERS

"I am concerned about it, I don't think we have it perfect. We have to do better, we have to learn from mistakes," Obama told a news conference in Madrid. "We know that we have had hackers in the White House," he added.

Concerns have been raised about the security of government information after the head of the FBI said presidential nominee Hillary Clinton's email servers may have been accessed by foreign actors when she was Secretary of State.