There is a CreateView method that dynamically creates a View and fills in fields that appear in the view with data from the SharedPrefernces file.
The first for (File loadFile: loadFiles) works correctly. It fills in data with views that are 100% in the SharedPrefernces file.
The second for (Map.Entry entry: usersPresets.getAll (). EntrySet ()) fills the view with data that may not exist in the specified file. There is - fills, no - goes further. And here is the problem.
public void CreateView(File[] loadFiles) { if (presetsStorage.exists()) { for (File loadFile : loadFiles) { //noinspection SpellCheckingInspection if (!loadFile.getName().contains("userpreset_")) { //noinspection UnnecessaryContinue continue; } else { if (loadFile.isFile()) { String presetsName = loadFile.getName(); presetsName = presetsName.substring(0, presetsName.length() - 4); usersPresets = getSharedPreferences(presetsName, MODE_PRIVATE); presetsContainer = (LinearLayout) findViewById(R.id.presetsContainer); View userPresetsView = getLayoutInflater() .inflate(R.layout.preset_fragment, presetsContainer, false); userPresetsView.findViewById(R.id.presetFragMenubtn) .setOnClickListener(viewClickListener); ((CircularSeekBar) userPresetsView.findViewById(R.id.presetFragA)). setProgress(usersPresets.getInt("a", 0)); ((CircularSeekBar) userPresetsView.findViewById(R.id.presetFragB)). setProgress(usersPresets.getInt("b", 0)); ((CircularSeekBar) userPresetsView.findViewById(R.id.presetFragC)). setProgress(usersPresets.getInt("c", 0)); TextView presetFragName = (TextView) userPresetsView .findViewById(R.id.userPresetName); presetFragName.setText(presetsName); presetFragName.setOnClickListener(viewClickListener2); presetsContainer.addView(userPresetsView); presetFragName.setText(presetsName.substring(11)); //Проблема в этом форе for (Map.Entry<String, ?> entry : usersPresets.getAll().entrySet()) { if (arr.contains(entry.getKey())) { // noinspection UnnecessaryContinue continue; } else { CardView flavor_cardView = (CardView) findViewById(R.id.flavor_cardView); final View usersFlavorsPreset = getLayoutInflater() .inflate(R.layout.preset_userflavor_fragment, flavor_cardView, false); ((TextView) usersFlavorsPreset.findViewById(R.id.tvUserFlavorPresetName)) .setText(entry.getKey()); ((TextView) usersFlavorsPreset.findViewById(R.id.tvUserFlavorPresetValue)). setText(String.valueOf(entry.getValue())); flavor_cardView.addView(usersFlavorsPreset); } } } } } } } I need to create as many new lines (View) as there are necessary data for this in the SharedPrefernces file. Now it works, but it creates views only on one line and with each iteration a handicap rewrites the values.
Screenshots of problems that can help to understand the essence (but this is not accurate) - https://drive.google.com/open?id=0Bx-Mv3rgZ3FyQWxWVzN2U294UVU
Prompt, please, where it is necessary to put for what values would not be rewritten in the same place. I hope, explained a little lucidly. If it's still not clear, I will try again.
UPDATE : Added to CardView LinearLayout, and all elements from two files are now displayed in one place. So now another question - what needs to be changed, so that the placement would be correct?
for (Map.Entry<String, ?> entry : usersPresets.getAll().entrySet()) { if (arr.contains(entry.getKey())) { // noinspection UnnecessaryContinue continue; } else { LinearLayout flavor_linear = (LinearLayout) findViewById(R.id.flavor_linear); final View usersFlavorsPreset = getLayoutInflater(). inflate(R.layout.preset_userflavor_fragment, flavor_linear, false); ((TextView) usersFlavorsPreset. findViewById(R.id.tvUserFlavorPresetName)).setText(entry.getKey()); ((TextView) usersFlavorsPreset. findViewById(R.id.tvUserFlavorPresetValue)).setText(String.valueOf(entry.getValue())); flavor_linear.addView(usersFlavorsPreset); } } 
usersPresetsarrayusersPresetsput in a separateCardView? - Iman