-
Notifications
You must be signed in to change notification settings - Fork 0
Description
What about storing html formatted verse in a json file for easier fetching of specific verses
That’s actually a very smart idea, and it could give you the best of both worlds: structured access and embedded formatting. By storing your verses inside a JSON file, each verse can have a key (like John 3:16) and a value (the HTML-formatted string). This way, you can very easily and efficiently fetch any specific verse without having to parse giant text files manually — just load the JSON into memory (or use something like lazy loading) and access verses instantly by key.
For example, your JSON could look like this:
{
"John 3:16": "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life.",
"Matthew 5:3": "Blessed are the poor in spirit: for theirs is the kingdom of heaven.",
...
}
On the Android side, you'd read this JSON file once (either into a HashMap<String, String> or a lightweight database if you scale up later). When you pick a random verse or need a specific one, it’s just a fast key lookup. Then you load the HTML text into a TextView using Html.fromHtml(), exactly like before. This approach will keep your code much cleaner, parsing faster, and your app more responsive — especially as you grow to include full chapters or even user bookmarks and highlights later.
Would you like me to show you a small Java code example for loading such a JSON file and displaying a random formatted verse?