2011-04-05 4 views
0

안녕 요청 결과를 테이블에 저장하고 싶습니다. 그 방법의 결과가 그 일을하기위한 테이블 호와 같아요? 내 코드에 오류가 있습니다. 모든테이블에 요청 결과를 저장하는 방법

public array getResult_libelle(int id) 
    { 
     array tab[] = null; 
     try 
     { 
      Cursor c = null; 
      c = db.rawQuery("select libelle from favori where _id="+id, null); 
      c.moveToFirst(); 
      tab = c.getString(c.getColumnIndex("libelle")); 
      c.close(); 
     } 
     catch(Exception e) 
     { 
      e.printStackTrace(); 
     } 
     return tab; 
    } 
+0

내가 그것을 –

+0

에서 오류 출력을 게시하시기 바랍니다,하지만 (instad를 추가 내가 넣어 함께 문제를 가지고 moveToNext – mobileDeveloper

답변

0
public ArrayList <String> getResult_libelle(int id) 
{ 
    ArrayList <String> tab = new ArrayList <Stringr>(); 
    try 
    { 
     Cursor c = null; 
     c = db.rawQuery("select libelle from favori where _id="+id, null); 
     c.moveToFirst(); 
     for(int i=0;i<c.getCount();i++){ 
      tab.add(c.getString(c.getColumnIndex("libelle"))); 
      c.moveToNext(); 
     } 

     c.close(); 
    } 
    catch(Exception e) 
    { 
     e.printStackTrace(); 
    } 
    return tab; 
} 
+0

코드 testet하지 코드에 오류가있는 응용 프로그램을 실행할 때 그것은 문제가되지 않습니다 로그 캣 – 2red13

+0

있어야 put 대신 List 대신 ArrayList), c.moveToNext()에 어떤 문제도 보이지 않는다. – mobileDeveloper

+0

코드가 수정 확인 – 2red13

0

먼저, 커서는 이미에만 열이 libelle 그래서 난 명시 적으로 필터링 할 필요가해야한다고 생각하지 않습니다 이름을 가진됩니다.

내가 직접

이 시도 것을 줄 커서에서 하나씩, 각 행의 데이터를 얻을 수 getString(i)를 사용한다 같아요.

관련 문제