查询获取结果列表?

时间:2011-12-17 09:44:00

标签: android sqlite

我有一个单行和6列的表。我如何查询数据库,以便我可以存储arraylist中的所有值并使用每个值显示它们?

我的代码:

List<String> list = new ArrayList<String>();  
          Cursor cursor = this.db.query(TABLE_NAME_MY_DETAILS, new String[] { "policy_number","policy_exp_date","last_name","first_name","DOB","emergency_contact" },
        null, null, null, null, null);  
          if (cursor.moveToFirst()) {  
             do {  
                list.add(cursor.getString(0));  
                list.add(cursor.getString(1));  
                list.add(cursor.getString(2));  
                list.add(cursor.getString(3));  
                list.add(cursor.getString(4));  
                list.add(cursor.getString(5));  
             } while (cursor.moveToNext());  
          }  
          if (cursor != null && !cursor.isClosed()) {  
            cursor.close();  
          }  
          return list;

0 个答案:

没有答案