@Override public boolean onOptionsItemSelected(MenuItem item) { int br = 1; switch (item.getItemId()) { case R.id.menu_settings: Intent i = new Intent(this, UserSettingActivity.class); startActivityForResult(i, RESULT_SETTINGS); break; case R.id.menu_upload: if (global.getLogin() != null) { brands = db.retriveBrand(); for (Brand bra : brands) { if (bra.getBrandStatus().equals("true")) { ++br; } } uploadList = db.retriveUpload(); if (br >= 2) { if (connection.isConnectingToInternet()) { try { new Load().execute(uploadList); } catch (Exception e) { // TODO: handle exception } Editor edit = preference.edit(); edit.putInt("upload", 2); edit.putInt("playMode", 2); edit.clear(); edit.commit(); db.resetTables(MySQLiteHelper.TABLE_NAME); db.resetTables(MySQLiteHelper.server_table); global.setLogin(null); Toast.makeText(home.this, "success", Toast.LENGTH_LONG).show(); finish(); } else { alert.showAlertDialog(home.this, "Warning", "Check your network connection", true); } } else { alert.showAlertDialog(home.this, "Warning", "You need to play atleast two brand", true); } } else { { Constants.name = preference.getString("name", null); Constants.age = preference.getString("age", null); Constants.gender = preference.getString("gender", null); if (Constants.name != null && Constants.age != null && Constants.gender != null) new InsertData().execute(); else alert.showAlertDialog( home.this, "Warning", "You are not logged in and no data to upload", true); } } break; } return true; }