我需要从文本文件中读取并将此数据插入数据库
文本文件包含行,每行包含以逗号分隔的数据
我执行此代码的运行没有错误
并且行成功读取
但数据未成功保存到数据库
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 from 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 well .