아래 쿼리에서 오류가 발생합니다.안드로이드에서 SqlLite 데이터베이스 구문 사용하기
오류는 유형 문자열을 찾지 못합니다.
내 검색어에 어떤 문제가 있습니까?
String selectQuery = "SELECT * FROM " + TABLE_CONTACTS + " WHERE " + KEY_TYPE + " ='" + type + "'";
내 로그인 고양이 내 로그인 고양이 02-14 16 : 33 : 17.925 : E/AndroidRuntime (25839) : java.lang.RuntimeException가 : 활동 ComponentInfo android.database.sqlite.SQLiteException를 시작할 수 없습니다 : 없음 이러한 열 : 유형 : 컴파일하는 동안 : Mycontacts SELECT * FROM WHERE 형 = '화이트리스트'
전체 쿼리 코드
public List<Contacts> getAllphContacts(String type) {
List<Contacts> contactList = new ArrayList<Contacts>();
// Select All Query
//String selectQuery = "SELECT * FROM " + TABLE_CONTACTS +KEY_TYPE + "=?"; //*tried this also
String selectQuery = "SELECT * FROM " + TABLE_CONTACTS + " WHERE " + KEY_TYPE + " ="+ type; //***this also not working
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
Contacts contact = new Contacts();
contact.setphid(Integer.parseInt(cursor.getString(0)));
contact.setphname(cursor.getString(1));
contact.setphnumber(cursor.getString(2));
contact.settype(cursor.getString(3));//********For whiteList*********//
// Adding contact to list
contactList.add(contact);
} while (cursor.moveToNext());
}
cursor.close();
db.close();
// return contact list
return contactList;
}
후 좀 더 코드, 제발! –
이 링크를 확인하십시오. http://stackoverflow.com/questions/15594716/android-sqlite-query-where-and-where –