I am trying to export my database to **CSV** file on external storage, but nothing happens when I click on my "Export data!" button.

Here is the code:

**SpsActivity**.java

```
@Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {
        case R.id.bStart:
            start.setVisibility(View.INVISIBLE);
            counter.setVisibility(View.VISIBLE);
            new CountDownTimer(9000, 1000) {

                @Override
                public void onTick(long millisUntilFinished) {
                    // TODO Auto-generated method stub
                    minutes = millisUntilFinished / 60000;
                    seconds = (millisUntilFinished / 1000) % 60;
                    counter.setText("Remaining: " + minutes + ":" + seconds);
                }

                @Override
                public void onFinish() {
                    // TODO Auto-generated method stub
                    counter.setText("Done!");
                    export.setVisibility(View.VISIBLE);
                }
            }.start();
            break;
        case R.id.bExport:
            ExportDatabaseCSVTask task = new ExportDatabaseCSVTask();
            task.execute();
            break;
        }
    }

private class ExportDatabaseCSVTask extends
            AsyncTask<String, Void, Boolean> {
        private final ProgressDialog dialog = new ProgressDialog(
                SpsActivity.this);

        @Override
        protected void onPreExecute() {

            this.dialog.setMessage("Exporting database...");
            this.dialog.show();

        }

        protected Boolean doInBackground(final String... args) {

            File dbFile = getDatabasePath("brojanje.db");
            DatabaseHelper dbhelper = new DatabaseHelper(
                    getApplicationContext());
            Log.v("SpsActivity", "Db path is: " + dbFile); // get the path of db

            File exportDir = new File(
                    Environment.getExternalStorageDirectory(), "");
            if (!exportDir.exists()) {
                exportDir.mkdirs();
            }

            File file = new File(exportDir, "brojanje.csv");
            try {

                file.createNewFile();
                CSVWriter csvWrite = new CSVWriter(new FileWriter(file));
                SQLiteDatabase db = dbhelper.getReadableDatabase(); // Cursor
                Cursor curCSV = db.rawQuery("SELECT * FROM izlazniRezultati.db",
                        null);
                csvWrite.writeNext(curCSV.getColumnNames());
                while (curCSV.moveToNext()) {
                    String arrStr[] = { curCSV.getString(0),
                            curCSV.getString(1), curCSV.getString(2),
                            curCSV.getString(3) };
                    csvWrite.writeNext(arrStr);
                }
                csvWrite.close();
                curCSV.close();
                return true;
            } catch (Exception sqlEx) {
                Log.e("SpsActivity", sqlEx.getMessage(), sqlEx);
                return false;
            }
        }

        @Override
        protected void onPostExecute(final Boolean success) {

            if (this.dialog.isShowing()) {
                this.dialog.dismiss();
            }
            if (success) {
                Toast.makeText(SpsActivity.this, "Export successful!",
                        Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(SpsActivity.this, "Export failed!",
                        Toast.LENGTH_SHORT).show();
            }
        }
    }

```

Here is the code for my DATABASE:
**DatabaseHandler**.java

```
public class DatabaseHelper extends SQLiteOpenHelper{

    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        // TODO Auto-generated constructor stub
    }
    public static final String KEY_ID = "_id";
    public static final String KEY_SMEROVI = "Smerovi";
    public static final String KEY_KATEGORIZACIJA = "Kategorizacija";
    public static final String KEY_VREDNOSTI = "Vrednosti";

    private static final String DATABASE_NAME = "brojanje.db";
    private static final String DATABASE_TABLE = "izlazniRezultati";
    private static final int DATABASE_VERSION = 1;

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        db.execSQL("CREATE TABLE " + DATABASE_TABLE + " (" + KEY_ID
                + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_SMEROVI
                + " TEXT NOT NULL, " + KEY_KATEGORIZACIJA
                + " TEXT NOT NULL, " + KEY_VREDNOSTI + " TEXT NOT NULL);");
    }
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub
        db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE);
        onCreate(db);
    }

    public void createEntry(String smer, String kat, String vrednost){

        SQLiteDatabase db = this.getWritableDatabase();

        //this is a key value pair holder used by android's SQLite functions
        ContentValues values = new ContentValues();
        values.put(KEY_SMEROVI, smer);
        values.put(KEY_KATEGORIZACIJA, kat);
        values.put(KEY_VREDNOSTI, vrednost);

        //ask the database object to insert the new data
        try {
            db.insert(DATABASE_TABLE, null, values);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            Log.e("DB ERROR", e.toString());
            e.printStackTrace();
        }
    }

}

```

So, I exported signed application, and tested it on my phone. There is no exported file in my phone. I guess it's some obvious error, but I am going crazy here, so please if you can help I'do appreciate!

Thanks in advance.