Note that there are some explanatory texts on larger screens.

plurals
  1. POretrieve data from Sqlite and store into CSV file
    text
    copied!<p>im trying to return Data from Database and save it on a file as CSV in SDcard and attach the file and email it, all this works perfect and the Data should be like this on the Excel.</p> <p><strong>Example</strong></p> <p>COLUMN A...........COLUMN B</p> <p>123123232..........John</p> <p>964803400..........Smith</p> <p>657484738..........Mike</p> <p>my problem is when i open the Excel the Data is displayed like this</p> <p>COLUMN A...........COLUMN B</p> <p>123123232..........</p> <p>964803400..........</p> <p>657484738..........</p> <p>John</p> <p>Smith</p> <p>Mike</p> <p>Here is the code <strong>Names.Java</strong></p> <pre><code>dbUser.open(); File root=null; try { // check for SDcard root = Environment.getExternalStorageDirectory(); Log.i(TAG,"path.." +root.getAbsolutePath()); //check sdcard permission if (root.canWrite()){ File fileDir = new File(root.getAbsolutePath()+"/fun/"); fileDir.mkdirs(); Log.d("PATH",fileDir.toString()); File file= new File(fileDir, "itisfun.csv"); FileWriter filewriter = new FileWriter(file); BufferedWriter out = new BufferedWriter(filewriter); String[] div = dbUser.getVname_Mnumber(sharedUsername1,product).toString().split(","); Log.d(sharedUsername1, product); Log.d("VVVVVVVVVV", dbUser.getVname_Mnumber(sharedUsername1,product).toString()); for (int i =0; i&lt;div.length;i++) out.write( div[i] +"\n" ); out.close(); } } catch (IOException e) { Log.e("ERROR:---", "Could not write file to SDCard" + e.getMessage()); } </code></pre> <p>Here is my <strong>DBadapter</strong></p> <pre><code>public String getVname_Mnumber(String date , String Vname) throws SQLException { String[] whereArgs = new String[]{date,Vname}; Cursor mcursor = db.rawQuery("SELECT MeterNumber,VendorName FROM " + SCAN_TABLE + " WHERE Date = ? AND VendorName = ? ",whereArgs); ArrayList&lt;String&gt; results = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; results1 = new ArrayList&lt;String&gt;(); while (mcursor.moveToNext()) { results.add(mcursor.getString(0)); results1.add(mcursor.getString(1)); } return results + ","+ results1; } </code></pre> <p>will appreciate your help</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload