SQLite upsert for android -


i have create next table:

final string sql_create_table_news_tape = "create table " + newstapeentry.table_name +                 " (" + newstapeentry.news_id + " integer primary key, " +                 newstapeentry.user_id + " integer not null, " +                 newstapeentry.content + " text, " +                 newstapeentry.created_at + " text, " +                  " foreign key (" + newstapeentry.news_id + ") references " +                 newstapeentry.table_name + " (" + newstapeentry.news_id + "), " +                 " unique (" + newstapeentry.news_id + ") on conflict update);"; 

but if make update mynews, every time insert each row in table... , need next result: when updating - firs check if current id exist, if true - update current row in table, if false - make insert! there small point, must done: if id exist, , row updating, must not overwrite empty fields default value. example: updating mynews, receive answer existed news_id, in answer not consist field created_at. after updating row field created_at must previous(not updated , not replaced default value).

will glad solutions!

update

when finish receive new data, doing bulckincert:

getcontentresolver().bulkinsert(contract.newstapeentry.content_uri, mcvarray); 


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -