安卓开发通讯录

在db中利用游标的移动来读取数据库表contect中表user的值,并且public ArrayList();
默认的构造器,将会以默认(16)的大小来初始化内部的数组.要注意前后字符的相匹配.

public ArrayList  getUserList(){

openDatabase();
Cursor cursor=db.query("user", null, null, null, null, null, null);
ArrayList list=new ArrayList();
while(cursor.moveToNext()){
HashMap map=new HashMap();
map.put("_id", cursor.getInt(cursor.getColumnIndex("_id")));
map.put("imageId",cursor.getInt(cursor.getColumnIndex("imageId")) );
map.put("name", cursor.getString(cursor.getColumnIndex("name")));
      map.put("mobilePhone", cursor.getString(cursor.getColumnIndex("mobilePhone")));
  map.put("officePhone", cursor.getInt(cursor.getColumnIndex("officePhone")));
map.put("familyPhone", cursor.getInt(cursor.getColumnIndex("familyPhone")));
map.put("position", cursor.getInt(cursor.getColumnIndex("position")));
map.put("company", cursor.getInt(cursor.getColumnIndex("company")));
map.put("address", cursor.getInt(cursor.getColumnIndex("address")));
map.put("zipCode", cursor.getInt(cursor.getColumnIndex("zipCode")));
map.put("email", cursor.getInt(cursor.getColumnIndex("email")));
map.put("otherContact", cursor.getInt(cursor.getColumnIndex("otherContact")));
map.put("remark", cursor.getInt(cursor.getColumnIndex("remark")));
list.add(map);
}
return list;

}




你可能感兴趣的:(安卓开发通讯录)