Question: I have form with a spinner control and a text box; and tables are stored in the SQLite database.

I am populating spinner inside onCreate method of activity. Is it right place to call database query & update ui?

Depending upon value user selects from spinner, i have to give auto suggestion in text box. (which control i can use instead of text box, i want to force user to select from list coming from database.)

Also i have heard about fragment, can anyone guide me is it helpful for improving performance of the application.

Answer: 
it would be better u call a function inside onCreate method and fill the spinner value in that function like

```
 protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.spinner);

    addItemsOnSpinner1();
}

 public void addItemsOnSpinner1() {

    Spinner spinner = (Spinner) findViewById(R.id.spinnerSource);
    List<String> list = new ArrayList<String>();
    list.add("sony");
    list.add("apple");
    list.add("samsung");
    list.add("htc");
    list.add("blackberry");
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, list);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Collections.sort(list);
    spinner.setAdapter(dataAdapter);

```

And for using fragment use this link[When should I use fragments in Android applications ? Why to use fragments?](https://stackoverflow.com/questions/8597769/when-should-i-use-fragments-in-android-applications-why-to-use-fragments)
You must populate your spinner with data from that moment on you want to provide it to the user. So just in the onCreate of the containing Activity. 

For more info I guess [Spinner | Android Developers](http://developer.android.com/guide/topics/ui/controls/spinner.html) .

Fragments give you the ability to create independent parts for your UI. For example a Fragment which contains a List and another showing detail information to the selected element. On Tablet you could display both beside each other. On a small display handheld device you have to display the list and on item selection the details. With Fragments you have reusability. Take a look here [Fragments | Android Developers](http://developer.android.com/guide/components/fragments.html) - I recommend to read this if you will use Fragments. It will save you the trouble.