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
Post a Comment