Skip to content Skip to sidebar Skip to footer

Java.lang.illegalargumentexception: Column 'foo' Does Not Exist Android

Numerous StackOverflow problems are similar, but it is not an issue of incorrect spacing in the query string. I have two tables, one for peers and one for messages, which has forei

Solution 1:

You are not selecting the PeerContract.NAME, MessageContract.MESSAGE_TEXT in your fetchAllMessages() method. Change it to this:

public Cursor fetchAllMessages(){
    String query = "SELECT " + MESSAGE_TABLE + "." + MessageContract._ID + ", "
            + MessageContract.MESSAGE_TEXT + ", "
            + PeerContract.NAME + ", "
            + PeerContract.MESSAGE_TEXT + ", "
            + MessageContract.SENDER 
            + " FROM " + MESSAGE_TABLE + " JOIN " + PEER_TABLE + " ON "
            + MESSAGE_TABLE + "." + MessageContract.PEER_FOREIGN_KEY
            + "=" + PEER_TABLE + "." + PeerContract._ID;
    return db.rawQuery(query, null);
}

Post a Comment for "Java.lang.illegalargumentexception: Column 'foo' Does Not Exist Android"