how i can read from text file and insert this data to database in android -


i need read text file , insert data database

the text file contain lines , each line contain data separated comma

i code running without error

and lines reads successfully

but data not save database

public void getfrom_text(){ string []message=null;

        bufferedreader br=null;         string name1, faculty1, deparment1, officenumber1, email1, phone1,officehour1;         long e;         try{             string scurrentline = null;              br =new bufferedreader(new inputstreamreader(getassets().open("ab.txt")));              scurrentline = br.readline();              while((scurrentline = br.readline()) != null){                  log.d("line file", scurrentline);             if(scurrentline!=null ){               message=scurrentline.split(",");               faculty1=message[0];                 deparment1=message[1];                 name1=message[2];                 officenumber1=message[3];                 phone1=message[4];                 email1=message[5];                 officehour1=message[6];                 db.open();                 db.insertrecord(faculty1,deparment1,name1,officenumber1,phone1,email1,officehour1);                 db.close();           }}}         catch (ioexception e1){             e1.printstacktrace();         }finally{             try {                 if (br !=null)br.close();              }catch (ioexception ex){                 ex.printstacktrace();             }         }      } insertrecord method work . 


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -