whenever I add a new value in an array it creates two rows with one empty row in listview. when i delete a value in array the value is removed but both row still exists.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listcontact); sharedPreferences=getSharedPreferences(preferences,Context.MODE_PRIVATE);
for(int i=1;i<=n+1;i++) {
String st=sharedPreferences.getString(String.valueOf(i), "");
conact_list.add(st);
}
ArrayAdapter adapter=new ArrayAdapter<String>(getBaseContext(),android.R.layout.simple_list_item_1,conact_list);
ListView cv= (ListView) findViewById(R.id.listview);
cv.setAdapter(adapter);
}
I have checked arraylist and arrayadapter both doesnt have empty value or extra size but in list view it displays as follow :

Log:
04-25 12:40:31.491 30892-30892/com.symbols.syedibrahim.phonetrack D/ERR﹕ entered 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack D/ERR﹕ + 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack D/ERR﹕ +93838394 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack D/ERR﹕ +947574748 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack D/ERR﹕ +87478494 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack D/ERR﹕ aA created[93838394, 947574748, 87478494] 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack D/ERR﹕ lv3count3list view count:0 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack D/ERR﹕ la
st.isEmpty()eg :for(int i=1;i<=n+1;i++) { String st=sharedPreferences.getString(String.valueOf(i), ""); if( ! st.isEmpty() ) { conact_list.add(st);} }