Page 261 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 261
return new SmartHome(cursor.getInt(0), cursor.getString(1), cursor.getInt(2),
Timestamp.valueOf(cursor.getString(3)));
}
public boolean isChange(String kind, boolean status)
{
//데이터 베이스의 값이 바뀔 경우 실행되는 함수.
SQLiteDatabase db =getReadableDatabase();
Cursor cursor= db.rawQuery("select status from home ",null);
//home이라는 데이터베이스에서 status(열) 부분을 가져옴.
cursor.moveToNext();
boolean led0= cursor.getInt(0)==1;
cursor.moveToNext();
boolean led1= cursor.getInt(0)==1;
cursor.moveToNext();
boolean led2= cursor.getInt(0)==1;
cursor.moveToNext();
boolean led3= cursor.getInt(0)==1;
cursor.moveToNext();
boolean led4= cursor.getInt(0)==1;
cursor.moveToNext();
boolean led5 = cursor.getInt(0)==1;
cursor.moveToNext();
int fan = cursor.getInt(0);
cursor.moveToNext();
boolean Gas= cursor.getInt(0)==1;
cursor.moveToNext();
int Ctn= cursor.getInt(0);
cursor.moveToNext();
switch (kind)
{
case "led0" : return (led0 != status);
case "led1" : return (led1 != status);
case "led2" : return (led2 != status);
case "led3" : return (led3 != status);
case "led4" : return (led4 != status);
case "led5" : return (led5 != status);
case "Gas" : return (Gas != status);
}
- 254 -