Android - How to make loading on first starting
<p>Hi it's my first question in stackoverflow sorry if i do something wrong.</p>

<p>My problem is that when i start the app for very first time i need to write the SQL data in the database. If i do that in onCreate() while it's writing the sql it's not showing the View so it's like freezing. And if i make loader there it's not showed because first of all ti want's to finish all the oncreate and after that to show the View. Then i made AlertDialog to run if SQL is empty to inform the user that in needs "instalation" and after confirm i wanted to make loading box while it's running inserting the SQL...</p>

<p>So my question is : How to make loading onCreate... at running of the activity... can u give me some good idea... here is the code i made:</p>

<pre><code>private DatabaseHandler db = new DatabaseHandler(this);

Context context;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    context = this;     

    if(db.getWordsCount() == 0)
    {           
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Instalation needed");
        builder.setMessage("Database need to be installed");
        builder.setPositiveButton("Ok", dialogClickListener);
        builder.setNegativeButton("Close", dialogClickListener);
        builder.show();
    }
}

DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int which) { 
        switch (which){ 
        case DialogInterface.BUTTON_POSITIVE:

                    ProgressDialog progress = new ProgressDialog(context);
              progress.setTitle("Instalation");
              progress.setMessage("Please wait...");
                progress.show();                
                db.insertWords(db);
                progress.cancel();
            break; 

        case DialogInterface.BUTTON_NEGATIVE: 
            finish();
            break; 
        } 
    } 
}; 
</code></pre>
