2012-12-05 136 views
-1

我使用sqlite开发android应用程序。当我运行下面的代码行时,我收到一个错误。搜索记录android

if(student_name.length()>0) 
    { 

     db.open(); 

     Cursor c= db.searchByName(student_name);//upto this all is fine 

     c.moveToFirst(); //when i debug, i found exception is on this line. 

     names=new String[c.getCount()]; 

     for(int i=0;i<names.length;i++) 
      {     
        names[i]=c.getString(1); 
        c.moveToNext();      
      } 

     db.close();        
} 

任何帮助,将不胜感激......

+1

请不要将错误信息保密。 –

回答

0

尝试使用while循环解析您的数据。

while(c.moveToNext()){} 

不使用c.moveToFirst()方法!!