In my project, I have Map.First, I switch to the position of the Wifi router, I look at the Wi-Fi list and select Operator2 and Mark it.Next. I move to another position, collect information about the same previous statement2 (I do not), then I go to another position, repeat it again.
I can select Wifi Operator for the first time. Next time I donβt know. How to block Private previously selected operator data and get operator data again. So help me how to fix this.

My code is:
public class WifiReceiver extends BroadcastReceiver { private WifiManager wifiManager; private PlanMapperActivity viewerActivity; private Context newContext; private String operator; private String macAddress; private int signalStrength; private String wifiMode; private int frequency; private String htMode; private String security; private int channelNumber; private AlertDialog wifiAlertDialog; private ListView wifiListView; private ProgressDialog progress; private Boolean checkWifiSelected; private Boolean checkServayStart; private String operatorName; List<ScanResult> wifiSRList; private static final String WPA2 = "WPA2"; private static final String WEP = "WEP"; private static final String EAP = "EAP"; private static final String STORED_OPERATOR = "com.kenturf.wifiheatmap.SELECTED_OPERATOR"; private int requiredLevel; private int ssidCount; public WifiReceiver(Context ctx,PlanMapperActivity planMapper) { this.viewerActivity = planMapper; this.newContext = ctx; } public WifiReceiver(WifiManager myWifiManager,ProgressDialog wifiProgress,Boolean isWifiSelected,Boolean isSurveyStart) { this.wifiManager = myWifiManager; this.progress = wifiProgress; this.checkWifiSelected = isWifiSelected; this.checkServayStart = isSurveyStart; } @Override public void onReceive(final Context context, Intent intent) { wifiSRList = wifiManager.getScanResults(); if (wifiSRList.size() == 0) { Toast.makeText(context,"wifi List 0",Toast.LENGTH_SHORT).show(); } if (checkWifiSelected) { LayoutInflater wifiLayout = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View wifiView = wifiLayout.inflate(R.layout.dialog_fragment_wifi,null); AlertDialog.Builder wifiDialog = new AlertDialog.Builder(context); wifiDialog.setCancelable(false); wifiDialog.setView(wifiView); wifiAlertDialog = wifiDialog.create(); wifiListView = (ListView)wifiView.findViewById(R.id.user_wifi_detail); } Collections.sort(wifiSRList, new Comparator<ScanResult>() { @Override public int compare(ScanResult lhs, ScanResult rhs) { return (lhs.level > rhs.level ? -1 : (lhs.level == rhs.level ? 0 : 1)); } }); if (checkWifiSelected) { String[] wifiListString = new String[wifiSRList.size()]; for (int i = 0; i < wifiSRList.size(); i++) { wifiListString[i] = (wifiSRList.get(i).SSID); } wifiListView.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, wifiListString)); wifiAlertDialog.show(); progress.dismiss(); wifiListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { operator = wifiSRList.get(position).SSID; macAddress = wifiSRList.get(position).BSSID; signalStrength = wifiSRList.get(position).level; frequency = wifiSRList.get(position).frequency; final String cap = wifiSRList.get(position).capabilities; final String[] securityModes = {WEP, WPA2, EAP}; for (int i = securityModes.length - 1; i >= 0; i--) { if (cap.contains(securityModes[i])) { security = securityModes[i]; } } setOperator(operator); GetSetClass.wifiOperator = operator; SharedPreferences sharedPref = context.getPreferences(Context.MODE_PRIVATE);
UPDATED RESPONSE:
private static final String STORED_FILE = "com.package.name.SELECTED_FILE"; private static final String STORED_OPERATOR = "com.package.name.SELECTED_OPERATOR";
Save data to SharedPreferences:
SharedPreferences sharedPref = context.getSharedPreferences(STORED_FILE,Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString(STORED_OPERATOR, operator); editor.apply();
Get data from SharedPreferences:
SharedPreferences shPref = context.getSharedPreferences(STORED_FILE,Context.MODE_PRIVATE); String savedOperator = shPref.getString(STORED_OPERATOR,null); Log.e("operator : ", "saved operator is : " + savedOperator);