开发学院手机开发Android 开发 Android 在模拟器上显示数据库中提取的信息的列表... 阅读

Android 在模拟器上显示数据库中提取的信息的列表

 2010-11-05 00:56:33 来源:WEB开发网   
核心提示:db.execSQL("update person set name=?,age=? where personid=?",new Object[] { person.getName(), person.getAge(),person.getId() });}public Person find(In

db.execSQL(

"update person set name=?,age=? where personid=?",

new Object[] { person.getName(), person.getAge(),

person.getId() });

}

public Person find(Integer id) {

SQLiteDatabase db = databaseHelper.getReadableDatabase();

Cursor cursor = db.rawQuery(

"select personid,name,age from person where personid=?",

new String[] { String.valueOf(id) });

if (cursor.moveToNext()) {

Person person = new Person();

person.setId(cursor.getInt(cursor.getColumnIndex("personid")));

person.setName(cursor.getString(1));

person.setAge(cursor.getInt(2));

return person;

}

cursor.close();

return null;

}

public void delete(Integer id) {

SQLiteDatabase db = databaseHelper.getWritableDatabase();

db.execSQL("delete fro person where personid=?", new Object[] { id });

}

public List< Person> getScrollData(int firstResult, int maxResult) {

List< Person> persons = new ArrayList< Person>();

SQLiteDatabase db = databaseHelper.getReadableDatabase();

Cursor cursor = db.rawQuery(

"select personid,name,age from person limit ?,?",

new String[] { String.valueOf(firstResult),

String.valueOf(maxResult) });// firstResult开始索引

while (cursor.moveToNext()) {// maxResult每页获取的记录数

Log.i("aa", "333333333333");

Person person = new Person();

person.setId(cursor.getInt(cursor.getColumnIndex("personid")));

person.setName(cursor.getString(1));

person.setAge(cursor.getInt(2));

persons.add(person);

}

cursor.close();

return persons;

}

public long getCount() {

SQLiteDatabase db = databaseHelper.getReadableDatabase();

上一页  1 2 3 4 5 6  下一页

Tags:Android 模拟器 显示

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接