title: Read Text File to Database in android
body: <p>I need to read data from a text file and save it to database.</p>
  
  <p>I have written this code but it is giving me a runtime error:</p>
  
  <pre><code>FATAL EXCEPTION: main
  java.lang.ArrayIndexOutOfBoundsException: length=5; index=5
  </code></pre>
  
  <p>My code is:</p>
  
  <pre><code>public void GetFrom_Text() {
  
      String []message=null;
  
      BufferedReader br=null;
      String name1, faculty1, deparment1, officeNumber1, email1, phone1;
      long e;
      try{
          String sCurrentLine = null;
  
          br =new BufferedReader(new InputStreamReader(getAssets().open("ab.txt")));
  
  
          while((sCurrentLine = br.readLine()) != null) {
  
              if(sCurrentLine != null )
                  message=sCurrentLine.split(",");
  
              faculty1 = message[0];
              deparment1 = message[1];
              name1 = message[2];
              officeNumber1 = message[3];
              phone1 = message[4];
              email1 = message[5];
              e = db2.insertRecord(faculty1, deparment1, name1, officeNumber1, phone1, email1, email1);
          }
      }
      catch (IOException e1) {
          e1.printStackTrace();
      } finally {
          try {
              if (br !=null)br.close();
          } catch (IOException ex) {
              ex.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>the lines in text file contain data such that:</p>
  
  <p>it,csa,Mohammad Bsoul,it239,4573,mbsoul@hu.edu.jo</p>
  
  <p>I need to split each record and save it to database
  and i need to see if the data is save it successfully to datbase</p>