2014-06-29 36 views
0

我該如何插入數組列表中的每第10行? 這是我的代碼:如何插入數組列表中的每第10行?

openDB(); 
    Cursor c = myDb.getSpalte(); 
    List<Integer> valueList = new ArrayList<Integer>(c.getCount()); 

    while (c.moveToNext()) {   
     valueList.add(c.getInt(1)); 

    } 
    c.close(); 
    closeDB(); 

回答

1
openDB(); 
    Cursor c = myDb.getSpalte(); 
    List<Integer> valueList = new ArrayList<Integer>(c.getCount()); 

    List<Integer> tenthRows = new ArrayList<Integer>(); 
    counter = 0; 
    while (c.moveToNext()) { 
     Integer value = c.getInt(1);  
     valueList.add(value); 
     counter++; 
     if(counter == 10) { 
      tenthRows.add(value) 
      counter = 0; 
     } 
    } 
    c.close(); 
    closeDB(); 
相關問題