“I want to thank God for keeping me alive and well,” she said, adding that she was “forever grateful” for the support of her fans and crediting the staff of Cedars-Sinai Medical Center in Los Angeles with saving her life.

Lovato, who canceled a show in Atlantic City that had been planned for two days after her hospitalization, suggested that she may not be returning to the public eye soon.

“I now need time to heal and focus on my sobriety and road to recovery,” she wrote.

Lovato has long spoken of her struggles with depression, eating disorders and addiction, belying her happy persona as a smiling star of the children’s show “Barney and Friends.”

A 2012 documentary, “Demi Lovato: Stay Strong,” showed how she used to snort cocaine several times a day before finding her way into rehab and reviving her career.

In June, Lovato released a song entitled “Sober” in which she indicated a relapse and apologizes in verse to her parents.

The singer, whose hits include “Sorry Not Sorry,” was rushed from her home to a hospital by emergency responders. It remains unclear on which drug she overdosed.

Her overdose prompted a flurry of statements of solidarity from fellow stars who praised her personality — although the attention also triggered a backlash by social media users, who noted that many non-celebrities suffer from drugs with little fanfare.