0
이 코드 줄에 문제가있어서 getInt 메서드에서 컴파일러 오류가 발생했습니다. 변수 KEY_HITS가 String이 아니고 int가 아니기 때문입니다. 이 문제를 어떻게 수정합니까?android에서 sqlite 데이터베이스의 컴파일러 오류를 해결하는 방법
total = total + c.getInt(KEY_HITS);
여기 코드가 더 있습니다.
public static final String KEY_ROWID="_id";
public static final String KEY_NAME="persons_name";
public static final String KEY_HITS="persons_hits";
public int getTotal() {
String[] columns = new String[] { KEY_ROWID, KEY_NAME, KEY_HITS };
Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null,
null, null);
int total = 0;
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
total = total + c.getInt(KEY_HITS);
}
return total;
}
감사합니다.이 기능은 완벽하게 작동합니다. – Kevik