Listview + Adapter - delete item and Refresh, not working - Android
<p>this question is is  similar to this
* <a href="http://stackoverflow.com/questions/4656841/android-listview-delete-item-and-refresh">Android - Listview delete item and Refresh</a>
and this (the same , but i added the full code here'to check if i have any problems in my code):  </p>

<p>please give me code examlpe. . .</p>

<p>can i call an intent to refrash my list ?</p>

<p>I cant refresh my adapter with :</p>

<pre><code>adapter.notifyDataSetChanged();
</code></pre>

<p>I tried:</p>

<pre><code>adapter.remove(adapter.getItem(pos));
</code></pre>

<p>but without success, just one time (weird...).</p>

<p>there is another answer there:</p>

<pre><code>Call that Activity once again Using Intent
</code></pre>

<p>sombody can give me the exact code for this (or for the adapter/cursor) ?</p>

<p>I am trying this for a couple of hours without success. </p>

<p>my full code:</p>

<pre><code>protected void onCreate (Bundle SavedInstanceState) {


    super.onCreate(SavedInstanceState);
    setContentView(R.layout.personalmessageview);

    headtitle= getIntent().getExtras().getString("head");

    setTitle(headtitle);


     personalresults = getIntent().getExtras().getStringArrayList("personalres");
     personalresultswithtime = getIntent().getExtras().getStringArrayList("personalrestime"); 



    // setListAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,personalresults));

     ListView list = (ListView)findViewById(R.id.listview_personal);    
    // ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, personalresults);
     list.setAdapter(adapter);
     registerForContextMenu(list);


     list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { 
            public boolean onItemLongClick(AdapterView&lt;?&gt; av, View v, int pos, long id) {


                 String time = personalresultswithtime.get(pos).toString();


                    Show_Alert_box(v.getContext(),"Please select action.",time,pos);


                return true;
            }
        });
</code></pre>

<p>public void Show_Alert_box(Context context, String message,String time,int position) 
                  final String timestamp = time;</p>

<pre><code>              final int pos = position;

             final AlertDialog alertDialog = new  AlertDialog.Builder(context).create();
                alertDialog.setTitle(getString(R.string.app_name));
                alertDialog.setButton("Delete", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {

                        try
                        {
                            db = databaseHelper.getWritableDatabase();


                            db.delete("messages","timestamp" + "=?", new String[] { timestamp }); 

                            Log.d("DB"," delete! ");

                           ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(PersonalMessageView.this, android.R.layout.simple_list_item_1, personalresults);


                                    adapter.remove(adapter.getItem(pos)); //not working t all! why ?

                            list.notify();
                            list.invalidate();


                            personalresults.remove(pos);
                            personalresultswithtime.remove(pos);

                            adapter.notifyDataSetChanged();

                            db.close();




                        }
                        catch(Exception e)
                        {

                        }
                } }); 
                alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        alertDialog.dismiss();
                } }); 

                alertDialog.setMessage(message);
                alertDialog.show();
</code></pre>

<p>}</p>
