如何在android中使用两个线程升级gridview,在xml布局中仅使用一个gridview

如何在android中使用两个线程升级gridview,在xml布局中仅使用一个gridview,android,sqlite,Android,Sqlite,我在gridview中有一些项,这些项是从sqlite显示的。现在,我使用另一个线程从json webservice获取数据,并将数据存储在sqlite中。现在,我想在同一个网格视图中显示更新的项以及现有项 private void displayUpdate(String Bid) { Log.w("Update cALL","Executing Update"); System.out.println("aeqw cursor that

我在gridview中有一些项,这些项是从sqlite显示的。现在,我使用另一个线程从json webservice获取数据,并将数据存储在sqlite中。现在,我想在同一个网格视图中显示更新的项以及现有项

  private void displayUpdate(String Bid) {

             Log.w("Update cALL","Executing Update");
            System.out.println("aeqw cursor that in display table value"+getid(Bid).getCount());
            Cursor cursorx =getid(Bid);

            int p=Integer.parseInt(Bid);
            System.err.println("Recieving Bid to displayUpdate method"+p);
            if (getid(Bid) != null)
            {
                while(cursorx.moveToFirst())
                {

                    Log.e("Entering Loop", "WHILE EXECUTING");
                    String temp_id1 = cursorx.getString(0);
                    System.err.println("Name related to Bid to displayUpdate method"+temp_id1);
                    final String temp_name1 = cursorx.getString(1);
                    System.err.println("Name related to Bid to displayUpdate method"+temp_name1);
                    String temp_author1=cursorx.getString(2);
                    String temp_desc1=cursorx.getString(3);
                    byte[] temp_image1 = cursorx.getBlob(4);
                    String temp_rating1 = cursorx.getString(5);
                    String temp_price1 = cursorx.getString(6);
                    String temp_update1=cursorx.getString(7);
                    System.err.println("Name related to Bid to displayUpdate method"+temp_name1);
                    mapIdUp.add(temp_id1);
                    mapNameUp.add(temp_name1);
                    mapAuthorUp.add(temp_author1);
                    mapDescUp.add(temp_desc1);
                    mapRatingUp.add(temp_rating1);
                    mapPriceUp.add(temp_price1);
                    mapUp.add(temp_image1);
                    mapUpdatedUp.add(temp_update1);
                        Log.e("temp_id from the sqlite", temp_id1);
                        Log.i(temp_name1, temp_name1);
                        Log.i(temp_desc1, temp_desc1);
                        Log.i(temp_rating1, temp_rating1);
                        Log.e(temp_update1,temp_update1);
                        String[] captionArray1 = (String[]) mapNameUp.toArray(new String[mapNameUp.size()]);
                    ItemsAdapter itemsAdapter1 = new ItemsAdapter(
                            Bookicon.this, R.layout.item,captionArray1);

                    gridView1=(GridView)findViewById(R.id.list);
                    gridView1.setAdapter(itemsAdapter1);
                    itemsAdapter1.notifyDataSetChanged();
                    gridView1.setOnItemClickListener(new OnItemClickListener() {
                        public void onItemClick(AdapterView<?> parent, View v, int position, long id)
                        {
                            Intent i = new Intent(getApplicationContext(), DetailsActivity.class);

                            i.putExtra("id", position);

                            startActivity(i);
                        }
                    });
                    break;
                }       
            }   

            }
在第二个线程中调用此方法以显示更新的书籍

此方法用于显示sqlite表中的所有项

     private void getDataAndPopulate() 
    {

         Log.w("hello","zyuk,");

        Cursor cursor = getEvents("bcuk_book");

        while (cursor.moveToNext())
        {
             String temp_id = cursor.getString(0);
             final String temp_name = cursor.getString(1);
             String temp_author=cursor.getString(2);
             String temp_desc=cursor.getString(3);
             byte[] temp_image = cursor.getBlob(4);
             String temp_rating = cursor.getString(5);
             String temp_price = cursor.getString(6);
             String temp_update=cursor.getString(7);
             mapId.add(temp_id);
             mapName.add(temp_name);
             mapAuthor.add(temp_author);
             mapDesc.add(temp_desc);
             mapRating.add(temp_rating);
             mapPrice.add(temp_price);
             map.add(temp_image);
             mapUpdated.add(temp_update);
                Log.e("temp_id from the sqlite", temp_id);
                Log.i(temp_name, temp_name);
                Log.i(temp_desc, temp_desc);
                Log.i(temp_rating, temp_rating);
                Log.e(temp_update,temp_update);
                String[] captionArray = (String[]) mapName.toArray(new String[mapName.size()]);
                ItemsAdapter itemsAdapter = new ItemsAdapter(
                        Bookicon.this, R.layout.item,captionArray);
                gridView=(GridView)findViewById(R.id.list);
                gridView.setAdapter(itemsAdapter);
                gridView.setOnItemClickListener(new OnItemClickListener() {
                    public void onItemClick(AdapterView<?> parent, View v, int position, long id)
                    {

                        Intent i = new Intent(getApplicationContext(), DetailsActivity.class);

                        i.putExtra("id", position);

                        startActivity(i);
                    }
                });

        }   
        }
问题是,我无法显示更新的项目,而它显示的是已存储的项目

如果我们假设当我用6更新新项目时,有类似于1,2,3,4,5的项目,即一条记录显示第一个项目,即1。如果更新2条记录,则只显示前两条记录

如何解决这个问题