java - android - loading json in expandable list view with scroll -


i have application download's , save json database storage .

i should view json objects in expandable list view , have lot of theme must have scroller !

i want know how parse json , load in array , use array making expandable list view ?

try {         url url = new url(gurl);         httpurlconnection c = (httpurlconnection) url.openconnection();         c.setrequestmethod("get");         c.setdooutput(true);         c.connect();         string path = environment.getexternalstoragedirectory()                 + "/h3s/db";         file file = new file(path);         string filename = fname;         file outputfile = new file(file, filename);         fileoutputstream fos = new fileoutputstream(outputfile);         inputstream = c.getinputstream();         byte[] buffer = new byte[1024];         int len1 = 0;         while ((len1 = is.read(buffer)) != -1) {             fos.write(buffer, 0, len1);         }         fos.close();         is.close(); 

and sample json response : (sorry json language persian , titles won't shown because of not utf-8) :

{ "dbversion":"4" ,  "groups":[ {     "id"    : 1,     "title" : "کامپیوتر",     "bg"    : "1.png" }, {     "id"    : 2,     "title" : "شیمی",     "bg"    : "2.png" }, {     "id"    : 3,     "title" : "برق Ùˆ الکترونیک",     "bg"    : "3.png" }, {     "id"    : 4,     "title" : "Ùیزیک",     "bg"    : "4.png" }, {     "id"    : 5,     "title" : "ریاضی",     "bg"    : "5.png" }, {     "id"    : 6,     "title" : "مکانیک Ùˆ هواÙضا",     "bg"    : "6.png" }, {     "id"    : 7,     "title" : "زیست",     "bg"    : "7.png" } ] } 

im ios developer , in ios grouped style uitableview don't know how can in android !

this can you. code parsing response.

  try {                     jsonobject jsonobject = new jsonobject(buffer.tostring());                     string dbversion= jsonobject.getstring("dbversion");                     jsonarray jagroups = jsonobject.getjsonarray("groups");                     (int = 0; < jagroups.length(); i++) {                           jsonobject jsobject = jagroups.getjsonobject(i);                         string id = jsobject.getstring("id");                         string title = jsobject.getstring("title");                         string bg = jsobject.getstring("bg");                      }                  } catch (jsonexception e) {                     // todo auto-generated catch block                     e.printstacktrace();                 } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -