A man who found his boyfriend stabbed to death in their bed was initially held by detectives on suspicion of his murder, jurors have heard.
Scott Hoyle was cautioned and questioned by police over the death of David Wilson, 49, who was stabbed seven times at their home in Southwick, Sunderland.
While still under the spotlight of suspicion, the 36-year-old boyfriend is claimed to bragged that he "got away with murder" and told someone he had "committed a murder in Sunderland".
He also borrowed books about serial killers after joining the library.
Mr Hoyle told Newcastle Crown Court on Wednesday that his words had been "twisted" by others and denied being responsible or being present when his partner was killed in the early
hours of December 14, 2014.
Prosecutors claim Mr Wilson was stabbed to death by Daniel Johnson, who had attacked and mugged Mr Hoyle and taken his keys, which he used to get into the flat and commit the
The 20-year-old denies murder and is being tried by a jury.
Mr Hoyle told jurors he had been "happy" in his relationship with Mr Wilson, who he admitted was flirtatious with other men, and had been looking forward to spending the upcoming
festive season with him.
But he added: "David had a lot of issues in Sunderland. A lot of people disliked the character."
Mr Hoyle told the court Mr Wilson was alive when he left him in the flat in the early hours to go to McDonald's but was dead when he got back later that morning, after being attacked
himself and going to hospital.
Jurors heard Mr Hoyle attended voluntarily at the police station after Mr Wilson's body was found and was held under caution and questioned.
When he was released from custody, the court heard Mr Hoyle was put up in a hostel at Seaton Carew where he befriended a couple living in the same accommodation.
Under cross-examination, Toby Hedworth, who defends Johnson, said Mr Hoyle had said statements to the couple such as "If I get away with it, at least I can say I got away with murder" and that Mr Wilson's past had "caught up with him".
Mr Hoyle said his words to the couple had been "twisted".
Mr Hoyle admitted joining a local library while in Seaton Carew and borrowing books about serial killers.
He told the court: "I wanted to read up on things.
"I wanted to investigate as much as I could on homicide cases and such.
"I was in a house with a partner then I was in a very grotty hostel. I didn't know what to do.
"One thing I sought to do was read up on as much as possible. I was under suspicion of murder at the time.
"I liked reading and such and thought it would be appropriate to under the circumstances."
The court heard Mr Hoyle was moved on from Seaton Carew to North Ormesby, in Middlesbrough.
There, it is claimed he knocked on a stranger's door to ask to use their phone then told them he had "committed a murder in Sunderland and been released on police bail".
Mr Hoyle told jurors that accusation is "wrong".
He added: "I haven't got a violent bone in my body, I am a pacifistic person."
Mr Hedworth asked Mr Hoyle if he had been involved in the attack on Mr Wilson and he replied: "No, I had no reason to."
Mr Hedworth then asked Mr Hoyle if he had been present during the attack and he replied: "No, I had no reason to be."
Johnson, of Mulberry Gardens, Gateshead, denies murder.
The trial continues.