sqlite - android reloading data from server makes duplicates -
i working on app , when try update of information user personal information call user information service once again updated data instead of updated data shows me old data. shows me updated data when logout app , sign in again, because @ logout delete table values , @ sign in fetches new values server. don't know happens please me in solving problem.
here how saving data db comes server dbhandler class
public boolean saveuserdata(contentvalues values , string tablename) { sqlitedatabase database = databasehundler.open(); try{ if(database != null) { if (values!= null) { database.insertwithonconflict(tablename, basecolumns._id, values, sqlitedatabase.conflict_replace); } return true; } }catch(exception e){} return false; }
edit
and tables class code
public void insertdata(contentvalues values) { controller.hundler.saveuserdata(values, tablename); }
and how getting data json
, inserting table:
jsonarray jarray = jobject.getjsonarray("data"); (int = 0; < jarray.length(); i++) { jsonobject dataobject = jarray.getjsonobject(i); string valueforfield; contentvalues value = new contentvalues(); controller control = (controller) context.getapplicationcontext(); for(int j=0; j<control.table_user.colmnnames.size(); j++){ string key = control.table_user.colmnnames.get(j); valueforfield = utility.getstringfromjsonobject(dataobject, key); string type = (valueforfield.equalsignorecase("null"))? "" : valueforfield; value.put(control.table_user.colmnnames.get(j), type); } control.table_user.insertdata(value); }
Comments
Post a Comment