public final static String SQL_RAWQUERY ="select id,name,password,regdate FROM tbl_users where id=1";
public ArrayList<HashMap<String, String>> getUserData(){
// DbHelper helper = new DbHelper(getApplicationContext());
Cursor cursor= this.getReadableDatabase().rawQuery(SQL_RAWQUERY, null);
if(cursor!=null){
startManagingCursor(cursor);
users = new ArrayList<User>();
cursor.moveToFirst();
while(!cursor.isAfterLast()){
User user = new User();
user.SetId(cursor.getInt(0));
user.SetName(cursor.getString(1));
user.SetPassword(cursor.getString(2));
// String dateString = cursor.getString(3);
// try{
// date = dateFormat.parse(dateString);
// }catch(ParseException e){
// date = new Date();
// }
// user.SetRegdate(date);
users.add(user);
cursor.moveToNext();
}
listUsers = new ArrayList<HashMap<String,String>>();
Iterator<User> iterator = users.iterator();
while(iterator.hasNext()){
User user = (User)iterator.next();
HashMap<String, String> map = new HashMap<String, String>();
map.put("id", String.valueOf(user.GetId()));
map.put("name", user.GetName());
map.put("password", user.GetPassword());
// map.put("regdate", dateFormat.format(user.GetRegdate()));
listUsers.add(map);
}
return listUsers;
}
return null;
}
------解决方案--------------------
看代码是没有啥问题。把数据库导出来看一下。不就一目了然。
------解决方案--------------------
肯定是出错了,主要是出错不抛异常没感觉