How to use notifyDataSetChanged
<p>My project simplify as below:
First, I use application method Data.java to save data.
It contain the data:</p>

<pre><code>private ArrayList&lt;String&gt; data = new ArrayList&lt;String&gt;();
public int getsize() {
return this.data.size();
}
public String getdata(int i) {
return this.data.get(i);
}
public void adddata(String s) {
return this.data.add(s);
}
</code></pre>

<p>My AActivity class onCreate as below:</p>

<pre><code>Data d = (Data)this.getApplication();
String test = new String[d.getsize()];
for(i = 0; i &lt; d.getsize(); i++) {
test[i] = d.getdata(i);
}
//to show in list
DataAdapter = new DataAdapter (this, test);
setListAdapter(DataAdapter);
</code></pre>

<p>And when button is click, startActivity the BActivity class.
In BActivity class, the code as below:</p>

<pre><code>Data d = (Data)this.getApplication();
d.adddata("newdata");
finish();
</code></pre>

<p>And AActivity class onResume() as below:</p>

<pre><code>@Override
public void onResume(){
super.onResume();
this.DataAdapter.notifyDataSetChanged();
}
</code></pre>

<p>But why the list is not update?
I confirm the data has be save.</p>

<p>My DataAdapter:</p>

<pre><code>public DataAdapter(Context ctxt, String[] d) {
this.data = new String[d.length];
myInflater = LayoutInflater.from(ctxt);
int i;
for(i = 0; i &lt; d.length; i++) {
data[i] = d[i];
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewTag viewTag;
if(convertView == null) {
convertView = myInflater.inflate(R.layout.row_bookmark_list, null);
viewTag = new ViewTag((TextView)convertView.findViewById(R.id.tv));
convertView.setTag(viewTag);
}
else {
viewTag = (ViewTag) convertView.getTag();
}
viewTag.tv.setText(data[position]);
}
class ViewTag {
TextView tv;
public ViewTag(TextView t) {
this.tv = t;
}
}
</code></pre>
