android - Insertion to SQLiteDatabase -


i wrote code:

// currentfriendstable // --------------------- //| _id | email | uname | // ---------------------  // ffriend class class ffriend {     string email, uname;     // getter , setter }  // add single friend database public long addfriend(ffriend friend) {     contentvalues values = new contentvalues();     values.put(currentfriendstable.column_email, friend.getemail());     values.put(currentfriendstable.column_uname, friend.getname());     return database.insert(currentfriendstable.table_name, null, values); }  // add list of friends database public void addlistoffriends(list<ffriend> listoffriend){     int lenghoflist = listoffriend.size();     (ffriend friend : listoffriend)         addfriend(friend); } 

i have 2 question here:

  1. when add values table using database.insert() function, adding _id automatically ? (i defined column _id primary key autoincrement)

  2. is scenario of calling addfriend(ffriend friend) function in addlistoffriends(list<ffriend> listoffriend) use of may change ?

1) primary key automatically added if define key as:

primary key autoincrement 

2) think good. (as suggested here way looping)

just suggestion: not use internal getter , setter in android. use if need or set value outside of target class (reference)


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -