title: How to fetch individual column from a table in android
body: <p>I am new in android any help in this will be appreciated.
  I am putting the Id,time,longitude and latitude in my table. My Problem is how to fetch them individually and put in an array. Here i fetch them in an single string.</p>
  
  <p>This is my Database class</p>
  
  <pre><code>public class Database{
      private static final String Column_Id = "Id";
      public static final String time = "Time";
      public static final String longitude = "Longitude";
      public static final String latitude = "Latitude";
  
      private static final String Table_Name = "Gps";
      private static final String Database_Name = "My_Database.db";
      private static final int Version = 1;
      private Context context;
      private SQLiteDatabase db;
      private DbHelper helper;
      public Database() {
          // TODO Auto-generated constructor stub
      }
  
  
      private static class DbHelper extends SQLiteOpenHelper {
  
          public DbHelper(Context context) {
              super(context, Database_Name, null, Version);
  
          }
  
          @Override
          public void onCreate(SQLiteDatabase db) {
  
              String Create_Database= "CREATE TABLE "
                      +Table_Name
                      + "("
                      + Column_Id
                      + " INTEGER PRIMARY KEY AUTOINCREMENT, "
                      + time
                      + " TEXT NOT NULL, "
                      + longitude
                      + " TEXT NOT NULL, "
                      + latitude
                      + " TEXT NOT NULL  );";
  db.execSQL(Create_Database);
  
  
          }
  
          @Override
          public void onUpgrade(SQLiteDatabase db, int oldversion, int newversion) {
  
              db.execSQL("DROP TABLE IF EXISTS " + Table_Name);
              onCreate(db);
          }
  
      }
      public Database(Context context) {
          this.context = context;
  
      }
  
      public Database open() {
          helper = new DbHelper(context);
          db = helper.getWritableDatabase();
          return this;
  
      }
  
      public void close() {
          helper.close();
      }
  
      public long insertRows(String time2,double d, double e){
                      ContentValues value=new ContentValues();
                          value.put(time, time2);
                          value.put(longitude, d);
                          value.put(latitude, e);
                          return db.insert(Table_Name,null,value);
                      }
     /*  public Cursor getAllRows(){
         Cursor cursor=db.query(Table_Name, new String[]{Column_Id,time,longitude,latitude}, null,null, null, null, null);
          return cursor;
          }
       */
      public String getData() {
          String anArray[]=new String[] {Column_Id,time,longitude,latitude};
          Cursor c=db.query(Table_Name, anArray, null, null, null, null, null);
          String result="";
  
          int id=c.getColumnIndex(Column_Id);
          int time1=c.getColumnIndex(time);
          int longitude1=c.getColumnIndex(longitude);
          int latitude1=c.getColumnIndex(latitude);
  
          for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){
              result=result+ c.getString(id)+ "          " +c.getString(time1)+ "      "+c.getString(longitude1)+"      "+c.getString(latitude1)+"\n";
          }
          return result;
      }
  
  
   }
  </code></pre>