Populating List from SQlite
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6685027/good-tutorial-for-sqlite-and-listview">Good Tutorial for SQLite and ListView</a>  </p>
</blockquote>



<p>I am trying to populate ListView from SQLite. What should I do at ?????? in code. Do I need to build a String[] OR is there any better solution ?</p>

<pre><code>Cursor cursor = assignment.numOfNewTask(empid);
        String[] sb = null;
        if (cursor.moveToFirst()) {
            do {    
                for(int i=0; i&lt;cursor.getCount(); i++){
            ?????   sb [i]= "\"" + cursor.getString(0) + "\",";
                }
            } while (cursor.moveToNext());

        }


    list = (ListView)findViewById(R.id.list); 
        list.setOnItemClickListener(new OnItemClickListener() { 

            public void onItemClick(AdapterView&lt;?&gt; adapterView, View v, int arg2,
                    long arg3) {
                //startActivity(new Intent(v.getContext(), TaskDetail.class));
            } 
        }); 
        ArrayAdapter&lt;String&gt; adapter2 = new ArrayAdapter&lt;String&gt;(this, R.layout.listitem, sb);
        list.setAdapter(adapter2);


        linear.addView(text);
        setContentView(linear); 
</code></pre>
