I got the data from webservice and insert them to database in activity onCreate() function. the code is as below:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.contact_person);
RunningService runningService = new RunningService();
runningService.insert(staff);
initView();
}
And the the code of insert() is as below:
public void insertAllStaff(Staff staff){
ContentValues values = new ContentValues();
values.put("name", staff.getName());
Uri uri = contentResolver.insert(CONTENT_URI, values);
}
Every time that I go into this activity, it will insert data to database, the data are the same.
Is there a method that I can go into this activity and it doesn't insert the same data to database?
Aucun commentaire:
Enregistrer un commentaire