如何将数组列表中的每第10行插入?

时间:2014-06-29 10:28:29

标签: java android sql arrays eclipse

如何将数组列表中的每第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 个答案:

答案 0 :(得分: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();