Android SQLite 인 스 턴 스 깊이 연구(4)

본문http://www.eoeandroid.com/thread-81914-1-1.html
업무
//        
sb.deleteCharAt(sb.length()-1);
SQLiteDatabase database= dbmanger.getWritableDatabase();
//execSQL   sql  
database.execSQL("delete from person where personid in("+sb+")",(Object[])ids);
}
}

//      
public List getdatePerson(int startResult,int maxResult){
List persons=new ArrayList();
SQLiteDatabase database= dbmanger.getWritableDatabase();
//Cursor                     

//rawQuery(String sql,String[]s)        sql          sql               ,        string  

Cursor cursor = database.rawQuery("select * from person limit ?,?",new String[]{String.valueOf(startResult), String.valueOf(maxResult)});

while(cursor.moveToNext()){
persons.add(new Person(cursor.getInt(0), cursor.getString(1), cursor.getShort(2)));
}
return persons;
}

//      
public Cursor getdateRawPerson(int startResult,int maxResult){
// List persons=new ArrayList();
SQLiteDatabase database= dbmanger.getWritableDatabase();
//Cursor                     
//rawQuery(String sql,String[]s)        sql          sql               ,        string  

return database.rawQuery("select personid as _id,name,age from person limit ?,?",new String[]{String.valueOf(startResult), String.valueOf(maxResult)});
}
//      
public long getcount(){
SQLiteDatabase database= dbmanger.getWritableDatabase();
//Cursor                     

Cursor cursor = database.rawQuery("select count(*) from person", null);
if(cursor.moveToLast()){
return cursor.getLong(0);
}
return 0;
}
}

좋은 웹페이지 즐겨찾기