The High Court has been told that Ireland's data retention laws, which were used to obtain evidence against convicted murderer Graham Dwyer, are vital for the detection, investigation, prosecution and prevention of serious crimes and should not be struck down.

Senior Counsel for the State and Garda Commissioner, Brian Murray, said the 2011 Communications (Retention of Data) Act, which allows telecommunication data to be retained, "treats everybody the same".

On the fourth day of Dywer's action, in which he claims the use of his phone records by prosecutors during his trial for the murder of Elaine O'Hara breached his privacy rights, Mr Murray said the general retention scheme as provided for under the act can be used not only by prosecutors but also to establish an accused person's innocence.

Mobile phone data showing a person's location at a particular time would support an alibi advanced by a suspect, he added.

Mr Murray said a more targeted data retention regime, which Dwyer's lawyers claim should be in place, would not work when it came to preventing or investigating potential terrorist attacks.

Such a scheme targeting people with criminal records, different socio-economic groups, or areas where crimes are thought more likely to occur are unworkable, and could be deemed racist, he said.

In Dwyer's case, he had never come to the attention of gardaí before this investigation, and lived in Foxrock in Dublin, which is not an area where many serious crimes are committed, he added.

He said that, while the case was not about national security, the civil action does have implications for the security of the state.

Mr Murray said evidence will be advanced about how a general data retention regime such as Ireland's has prevented attacks in the UK, from experts including British barrister David Anderson QC, a former independent reviewer of terrorism legislation in the UK, and Professor Michael Clarke, who is an expert in defence studies.

Dwyer claims the 2011 Communications (Retention of Data) Act was introduced to give effect to a 2006 European Union directive concerning the retention and use of data.

In 2014, the European Court of Justice found the directive was invalid.

Dwyer's claims the 2011 act suffers from the same flaws identified by the ECJ.

He claims certain provisions of the 2011 laws breach his privacy rights under the Irish Constitution, European Convention on Human Rights and EU Charter.

In his action, the 45-year-old is seeking various declarations that his privacy rights have been breached.

The application is opposed, and the respondents say Dwyer is not entitled to any of the declarations sought.

Outlining the State's arguments, Mr Murray said Dwyer knew in October 2013 following his arrest that data relating to his phone had been obtained and used by gardaí.

The obtaining of that data was perfectly lawful, he said, and happened months before the ECJ's decision.

Mr Murray said Dwyer did nothing for some time about his complaints in relation to the retention of his mobile phone data.

His High Court challenge was lodged around the time of his 2015 trial.

Mr Murray said Dwyer could have taken steps to have his civil action heard before his trial, which would have benefitted not just the State but also his victim's family.

The action, before Mr Justice Tony O'Connor, continues next Tuesday.