2014-02-05 84 views
0

我想解析所有的調用日誌,但只有第一次調用結束時,遊標是不受限制的。它拋出兩種例外(日期和時間)遊標索引出界

預先感謝您

我的代碼是在這裏:

if (c != null && c.getCount()>0) { 
     if (c.moveToFirst()) {! 
      type = Integer.parseInt(c.getString(c.getColumnIndex(CallLog.Calls.TYPE))); 
      do { 
       try{ 
        Log.d(this.getClass().getName(),"Date is "+c.getString(c.getColumnIndex(Calls.DATE))); 
       }catch(Exception e){ 
        Log.d(this.getClass().getName(),"Exception: DATE IS NULL!!"); 
       } 
      //String timestamp = c.getString(c.getColumnIndex(Calls.DATE)); 
       //Log.d(this.getClass().getName(),"timestamp is: "+timestamp); 
       try{ 
        long duration= c.getLong(c.getColumnIndex(CallLog.Calls.DURATION)); 
       }catch(Exception e){ 
        Log.d(this.getClass().getName(),"Exception: DURATION IS NULL!!"); 
       } 
       //callDuration.put(timestamp, duration); 
      } 
      while (!c.moveToNext()); 
     } 
    } 

回答