title: Fetch and store a column values from sqlite in android(java) array
body: <p>I want to store the values of a particular column in the array, As I am a fresher I don't know how to do this. I am getting values from sqlite as </p>
  
  <pre><code>1
  2
  123
  432
  3
  5
  </code></pre>
  
  <p>I want to store these values in string array. Please tell me I am not finding any appropriate example by googling about this.. thanx in advance.</p>
  
  <pre><code>public void fun(String query){
      Cursor cursor = db.rawQuery(query, null);
  
      try{
          String[] arr = new String[cursor.getCount()];
          if(cursor != null){
              while(cursor.moveToNext()){
                  for(int i = 0; i &lt; cursor.getCount(); i++){
                      arr[i] = cursor.getString(0).trim();
  
                  }
                  cursor.moveToNext();
              }
              cursor.close();
          }
  
      }finally{
          cursor.close();
      }
  
  }
  </code></pre>
  
  <p>Here query is </p>
  
  <pre><code>SELECT &lt;COLUMN_NAME&gt; FROM &lt;TABLE_NAME&gt; WHERE &lt;CONDITION&gt;;
  </code></pre>
  
  <p>I think I am doing it wrong please correct my errors...</p>