java - Change csv file path to internal storage -


I'm doing a small app that inserts people and then if I want to export it to CSV I , But it is exporting to the file's emulator SD card and I want to export it so that there is internal storage (download or other place). I have already searched here that I can get a reply, but I have not found anything that has resolved my problem.

  file dbFile = getDatabasePath ("androidituts"); File exportDir = new file (environment .getExternalStorageDirectory (), ""); If (! ExportDir.exists ()) {exportDir.mkdirs (); } File file = new file (export dir, "teste.csv"); Try {file.createNewFile (); CSVDriver CSVRert = new CSVRIIeter (new filewriter (file)); Cursor curCSV = mydb.rawQuery ("test from selection", blank); CsvWrite.writeNext (curCSV.getColumnNames ()); While (curCSV.moveToNext ()) {string arrStr [] = {curCSV.getString (1)}; csvWrite.writeNext (arrStr); } CsvWrite.close (); curCSV.close (); } Hold (exception sqlEx) {Log.e ("main activity", sqlEx.getMessage (), sqlEx); }   

Does anyone know that I can change the file path ?? I think this environment is part of the Environment.getExternalStorageDirectory, but I sometimes change it for something else:

  E / MainActivity (1519): Open fail: ENOENT (such a File or directory) E / MainActivity (1519): java.io.IOException: Open failed: ENOENT (no such file or directory)    

Hope this will help

 try  {file exportDir = new file (myDir +" / text / ", filename); If (exportDir .getParentFile () .mkdirs ()) {exportDir .createNewFile (); FileOutputStream fos = New FileOutputStream (exportDir); Fos.write (outputString.getBytes ()); Fos.flush (); Fos.close (); }} Hold (exception e) {e.printStackTrace (); }    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -