mercredi 28 janvier 2015

Android SQL Lite query does not providing result

I want to get my message from table ChatMessage according to user. what kind of syntex i am writing wrong


here is my class



public List<ChatMessage> getAllMessageByThreadId(String login_user_id, String msg_receiver_user_id) {

Log.d("loginUserInfoId", "1loginUserInfoId = " + login_user_id + " recieverUserInfoId = " + login_user_id);

List<ChatMessage> chatMessages = new ArrayList<ChatMessage>();

SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery("SELECT * FROM "+TABLE_CHAT_MESSAGE+" WHERE SenderUserInfoId="+login_user_id+" AND ReceiverUserInfoId="+msg_receiver_user_id+" OR SenderUserInfoId="+msg_receiver_user_id+" AND ReceiverUserInfoId="+login_user_id, null);
}


what is the best syntax to write this kind of query?


Aucun commentaire:

Enregistrer un commentaire