-3

How to display json data from assets folder in android studio into Recylerview

Something like this:

{
  "book": "Luke",
  "chapters": 
  [
  {
  "chapter": "1",
   "verses":
  [
  {
   "1": "Forasmuch as many have taken in hand to set forth in order a declaration 
        of those things which are most surely believed among us,"
  }
  ]
  }
  ]
  }
Elsunhoty
  • 1,609
  • 14
  • 27
Muloni Bryan
  • 11
  • 1
  • 4

1 Answers1

0

They are many ways to do this based on the needs of your code.

One way, and the most simple, is doing the next steps:

  • Read JSON from Asset an manage it as JSONObject without creating any model class.
  • Read the array of elements you want to display from that JSONObject
  • Create a custom Adapter to display objects from that array.

You can find some similar example here

ezefire
  • 782
  • 5
  • 18
  • What am failing to get is the book, chapter and verse. – Muloni Bryan Mar 20 '18 at 08:23
  • How can i loop through this array to retrieve single item:["Genesis", "Exodus", "Leviticus", "Numbers", "Deuteronomy", "Joshua", "Judges", "Ruth", "1 Samuel", "2 Samuel", "1 Kings", "2 Kings", "1 Chronicles", "2 Chronicles", "Ezra", "Nehemiah", "Esther", "Job", "Psalms", "Proverbs", "Ecclesiastes", "Song of Solomon", "Isaiah", "Jeremiah", "Lamentations", "Ezekiel", "Daniel", "Hosea", "Joel", "Amos", "Obadiah", "Jonah", "Micah", "Nahum", "Habakkuk", "Zephaniah", "Haggai", "Zechariah", "Malachi", "Matthew", "Mark", "Luke", "John", "Acts" ] – Muloni Bryan Mar 22 '18 at 05:33