java - 如何在数组列表中插入每 10 行?

标签 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();

最佳答案

 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();

关于java - 如何在数组列表中插入每 10 行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24475194/

相关文章:

mysql - 当绑定(bind)参数为空时,视为 "select all"

sql - 正确命名表的 id 字段

mysql - MYSQL表中的约束?

java - 将方法传递给方法的解决方法?

android - 与observeOn组合时RxJava的startsWith操作符被忽略

android - 自定义 Android 相机应用程序,相机预览问题

java - 如何使用代码动态更改 TextInputLayout 错误颜色和错误文本大小

java - 如何使用CRC32?

java - java和sql如何获取同一列的信息

java - 简单的 WebApp 重定向到错误页面