MOSCOW — The lawyer for an American man being held in Moscow on suspicion of spying said on Tuesday that his client was given a flash drive containing Russian “state secrets” before he was arrested, but did not know he had them and had not looked at them.

Paul Whelan, a former US Marine, was detained in Moscow at the end of December. The arrest raised speculation that he could be swapped for one of the Russians held in the U.S., such as gun rights activist Maria Butina, who has pleaded guilty to acting as a foreign agent in the US

Whelan made his first public appearance in court on Tuesday to hear the appeal of his arrest. The judge upheld the previous ruling that ordered him to be kept behind bars at least until the end of February.

Whelan was kept in a glass cage and did not speak to reporters.

Spying charges carry a prison sentence of up to 20 years in Russia.

Whelan’s lawyer, Vladimir Zherebenkov, told Russian news agencies on Tuesday that when his client was detained at a Moscow hotel at the end of December, he had something with him that contained “state secrets.”

The lawyer said Whelan was a frequent visitor to Russia and that he asked an unnamed person to email him something about travel around the country. Whelan reportedly was not able to download it and then asked that person to put it on a flash drive.

“He was expecting to see on the flash drive some personal information like pictures or videos, something like that, about that person’s previous trips around Russia,” Zherebenkov told reporters. “We don’t know how the materials that contain state secrets ended up there.”

The lawyer said the American was detained before he could open the files.

Zherebenkov also said it was not clear what has happened to the person who reportedly gave the flash drive to Whelan.

Zherebenkov said investigators have not yet disclosed which country he is accused of spying for.

Whelan holds US, Canadian, British and Irish citizenships.

Whelan, 48, was discharged from the Marines for bad conduct. He works as the global security director for a US automobile parts manufacturer and lives in Michigan. His family has said he was in Moscow to attend a wedding.