WASHINGTON (AP) — Supreme Court Justice Sonia Sotomayor got some unsolicited health advice the last time she wrote a book.

The justice was diagnosed with diabetes as a child and discussed it as part of her 2013 autobiography. That prompted a grandmother to write. The woman reported she was using newer technology to manage her diabetes than Sotomayor, and she had a message for the justice: “I’m much older than you are, and if I can do it you can do it, too.”

“I still remember that letter, challenging me to become more modern,” Sotomayor said Saturday in an interview with The Associated Press. Sotomayor said encouragement from the woman and from children pushed her to explore using the device she does now. A sensor implanted in her stomach helps her monitor what her blood sugars are.

“I consider myself a life-long learner and, despite that, I was a little resistant and it helped break my resistance,” she said of the woman’s letter.

Sotomayor was speaking ahead of the publication this coming week of two new autobiographical books, this time aimed at children. One is a picture book for elementary school readers. The other, aimed at middle school readers, is an abridged version of her 2013 memoir “My Beloved World.” Now, when she talks about diabetes in the middle school book, she notes she uses a device called a continuous glucose monitor.

Sotomayor, 64, says her cousin and close friend Miriam Gonzerelli was the person who pushed her to adapt her memoir for middle schoolers. Gonzerelli, a bilingual language arts teacher, has for years been using excerpts from Sotomayor’s original autobiography in her classroom at Turn of River Middle School in Stamford, Connecticut. But some of the language was difficult for her students, who are learning English.

Gonzerelli said in a telephone interview she quickly realized she “needed something else to help the kids.” ”I wanted them to have access to Sonia’s amazing story,” Gonzerelli said. She said her students, who are mainly from Central America, connect with the nation’s first Hispanic justice and feel special because their teacher is her cousin.

Now, Sotomayor’s middle school book, called “The Beloved World of Sonia Sotomayor,” retains the core of her original memoir but is adapted for younger readers. Like the earlier book, it begins with Sotomayor’s childhood diabetes diagnosis and then takes readers through her life, from growing up poor in the Bronx and the death of her father at age 9 to college at Princeton, law school at Yale and her work as a young lawyer. A Spanish version will follow shortly.

Quoting from her book Saturday, Sotomayor said the reason she has written all of her books is that: “People, I add children, who live in difficult circumstances need to know that happy endings are possible.”

As for changes to the book, Gonzerelli suggested a family tree to help young readers keep track of the aunts, uncles and cousins in the book. Gonzerelli said that after Sotomayor’s original memoir came out she sometimes would draw one for adult friends who got lost. Sotomayor said she debated different ways of shortening the book. One section she considered removing describes a seance at her grandmother’s home, but Gonzerelli pushed her to leave in the scene, one of her students’ favorites.

Sotomayor, who became a justice in 2009, will be traveling nationwide to promote the new books. In January she’ll go to Puerto Rico, where her family is from and which she writes about.

On Saturday she spoke about the books at the Library of Congress National Book Festival in Washington, telling a packed audience that reading books “opened the world to me.” The picture book she has written, also out this week and called “Turning Pages: My Life Story,” is her life story told through books that shaped her, from the comic book superheros that gave her the courage as a child to give herself insulin shots to “Nancy Drew,” which she writes “fired my imagination.” The book is simultaneously being published in Spanish.

Sotomayor spoke with Librarian of Congress Carla Hayden and also answered audience questions. Asked by a father about how to help his son appreciate feminism, the third female Supreme Court justice answered in part by recommending the recent documentary “RBG” about her colleague Justice Ruth Bader Ginsburg, a legal trailblazer in the area of women’s rights.

To a 9-year-old girl who asked for advice on becoming president, Sotomayor recommended studying hard. “You have to read a lot about a lot of things, especially if you’re president,” Sotomayor said to laughter and then sustained applause from a crowd sitting less than a mile from the White House.

Asked how she retains her “hopeful outlook in these challenging times,” the liberal justice answered: “We don’t have a choice, do we?” She noted that because she’s a justice she can’t get involved in politics. “But you can,” she said. “So get out there and make a better world.”

___

Follow Jessica Gresko on Twitter at http://twitter.com/jessicagresko