title: read data from database and show it in GridView in android
body: <p>how we can read data from database and show them in grid in android?
  i see codes like this :</p>
  
  <pre><code>public class DataAdapter extends BaseAdapter
  {
      Context mContext;
      private String [] id = {"S001","S002","S003","S004","S005","S006","S007"};
      private String [] name={"Rohit","Rahul","Ravi","Amit","Arun","Anil","Kashif"};
      private LayoutInflater mInflater;
      public DataAdapter(Context c)
      {
          mContext=c;
          mInflater = LayoutInflater.from(c);
      }
  
      public int getCount()
      {
          return id.length;
      }
  
      public Object getItem(int position)
      {
          return position;
      }
  
      public long getItemId(int position)
      {
          return position;
      }
  
      public View getView(int position, View convertView, ViewGroup parent)
      {
          ViewHolder holder=null;
          // convertView=null;
          if(convertView==null)
          {
              convertView = mInflater.inflate(R.layout.customgrid,
                                                                      parent,false);
              holder = new ViewHolder();
              holder.txtId=(TextView)convertView.findViewById(R.id.txtId);
              holder.txtId.setPadding(100, 10,10 , 10);
              holder.txtName=(TextView)convertView.findViewById(R.id.txtName);
              holder.txtName.setPadding(100, 10, 10, 10);
  
              if(position==0)
              {                             
                  convertView.setTag(holder);
              }
          }
          else
          {
              holder = (ViewHolder) convertView.getTag();
          }
          // holder.txtId.setText(id[position]);
          holder.txtId.setText(id[position]);
          holder.txtName.setText(name[position]);
          return convertView;
      }
  
      static class ViewHolder
      {
          TextView txtId;
          TextView txtName;
      }
  }
  
  //------------main---------------------------------------------
  
  public class GridViewDataActivity extends Activity {
      EditText name;
      GridView gridview;
  
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          gridview = (GridView) findViewById(R.id.gridview);  
          gridview.setAdapter(new DataAdapter(this));
      }
  }
  </code></pre>
  
  <p>same way i want to show data from sqlite DB.</p>