Zaid Iqbal
Zaid Iqbal

Reputation: 1682

Android SQLiteopen Database connection causing exception

03-12 16:56:25.652: E/Database(334): Failure 1 (near "tablefriends": syntax error) on 0x29b268 when preparing 'create tablefriends(_id integer primary key autoincrement,name text not null,address text);'.

I have debugged the code and found exception on 4th line of this given function:

public Boolean addFriend(FriendData friendData){

ContentValues newFriendValues=new ContentValues();
newFriendValues.put(FriendsMetaData.COLUMN_FRIEND_NAME, friendData.getFriend_Name());
newFriendValues.put(FriendsMetaData.COLUMN_ADDRESS,friendData.getFriend_Adress());

long id=friendsDB.insert(FriendsMetaData.TABLE_NAME, null, newFriendValues);
if(id==-1){
    return false;
}
else
    return true;    
}

Upvotes: 0

Views: 93

Answers (1)

Egor
Egor

Reputation: 40203

Maybe you mean "create table friends", not "create tablefriends", that's why it throws the exception. Hope this helps.

Upvotes: 1

Related Questions