This is how i add shared preferences
ct = sp.getInt("count", 0);
if (ct > 0) {
for (int i = 0; i <= ct; i++) {
list.add(sp.getString("Value[" + i + "]", ""));
}
}
adp = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, list);
Listtt.setAdapter(adp);
btnad.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
sped.putString("Value[" + ct + "]", editText.getText().toString());
sped.commit();
list.add(sp.getString("Value[" + ct + "]", ""));
ct += 1;
sped.putInt("count", ct);
adp.notifyDataSetChanged();
}
});
And by this i can successfully delete Sharedprefrences Value and remove it from list
sp.edit().remove("key_to_remove").apply();
adp.remove("name_to_rmv");
adp.notifyDataSetChanged();
Now my problem is that it leaves the blank space when i call it back just like closing activity and opening it again the value i have deleted has the blank space . Just like this image below i have deleted " two " but when i close and open my application it gives me blank space
how i fill adapter
ct = sp.getInt("count", 0);
if (ct > 0) {
for (int i = 0; i <= ct; i++) {
list.add(sp.getString("Value[" + i + "]", ""));
}
}
adp = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, list);
Listtt.setAdapter(adp);
.