title: how to store custom arraylist into sqlite and retrieve it
body: <p>i need to store my custom arraylist int sqlite db and retrieve it .</p>
  
  <p>the arrylist am using is </p>
  
  <pre><code>List&lt;LessonContent&gt; list = new ArrayList&lt;LessonContent&gt;(); 
  </code></pre>
  
  <p>lessonContent is an object with </p>
  
  <pre><code> public LessonContent(String n, String a, String c) {
          node = n;
          attribute = a;
          content = c;
  
      }
  </code></pre>
  
  <p>and i store it in list as this way..</p>
  
  <pre><code>LessonContent textobj = new LessonContent(tagname,type,content);
                                   list.add(textobj);
  </code></pre>
  
  <p>and i have stored it in sqlite this way.. because i read some other questions that we cannot able to store the arraylist directly to sqlite so convert it into json string.</p>
  
  <pre><code>// saving list to sqlite db
      JSONObject json = new JSONObject();
  
  json.put("uniqueArrays", new JSONArray(list));
  String arrayList = json.toString();
  
      Lessons lns =new Lessons(lesson_id,subject,chapter,arrayList);
      db.addContent(lns);     
  </code></pre>
  
  <p>towards this codes there is no issues...</p>
  
  <p>now i need to read the stored datas from sqlite..</p>
  
  <p>for that i use this piece of code..</p>
  
  <pre><code>Lessons lsn = db.getContent(lesson_id);
  String xmlcontent = lsn.getLesson();
        JSONObject json = null;
  
  json = new JSONObject(xmlcontent);
  
  list = (List&lt;LessonContent&gt;) json.optJSONArray("uniqueArrays");
  </code></pre>
  
  <p>i got error this stage as cannot cast a json object to list..</p>
  
  <p>please any one know the correct way to store my arraylist in db and read it back..</p>