A Sun journalist has described the moment he realised his newspaper had handed over his emails to police – despite his "moral and ethical" duty not to betray his sources.
Jamie Pyatt, 52, told his trial that he worked "loyally" for the tabloid for 25 years and everything he did there was "sanctioned".
But in November 2011, he found himself locked up in a police cell and questioned by Elveden officers.
The Thames Valley district reporter is on trial with news editor Chris Pharo, 46, for paying a Surrey police officer £10,000 for tips between 2002 and 2011.
Both defendants have denied the charge of aiding and abetting the police officer identified as 2044 to commit misconduct in a public office.
Giving evidence at the Old Bailey, Pyatt said he told investigators he had never paid a police officer, but admitted that was a lie which he now regrets.
He told jurors: "I had been arrested in November 2011.
"I had been taken to a police station, fingerprinted, DNA'd, photographed and held in a cell on my own for six-and-a-half hours before a solicitor arrived.
"As far as I was concerned I had never done anything wrong.
"I'm frightened, fearful, wondering what on earth I was doing there.
"I was asked if I had ever paid a police officer.
"It was a lie.
"I realised the position I had been put in by my company.
"I had worked loyally for the Sun for 25 years, approximately a year before that as a contract worker.
"I trusted entirely my newspaper during those 25 years.
"I worked as I was sanctioned to do by them.
"I worked as far as I was concerned within the law.
"All of a sudden, as soon as the Bribery Act had come in in 2011, everything changed.
"I suddenly found that my company had decided to hand all my emails over to the police."
Pyatt told jurors that under the Editors' Code, which parent company News International had signed up to, confidentiality of sources was "sacrosanct".
He said: "We never betray a source.
"We have got a moral and ethical duty never to betray a source."
The defendant said he would be prepared to go to prison rather than reveal a source, and it was his desire to protect his confidential contact that led him to lie to police.
Pyatt told the court that he was "given" officer 2044 as a contact by the Sun news desk in 2000 and there was no dispute that he was paid for information.
His lawyer Richard Kovalevsky QC asked: "In all the time do you think you have ever committed an offence in terms of a journalistic enterprise?"
Pyatt said: "No I don't."