I want to change the sqlite database .db file to excel.
But I am not able to find what exactly I have to do. Can anybody please elabor
add this jar file opencsv-1.7.jar http://www.java2s.com/Code/Jar/o/Downloadopencsv17jar.htm
And then use this code
public class ExportDatabaseToCSV{ Context context; public ExportDatabaseToCSV(Context context) { this.context=context; } public void exportDataBaseIntoCSV(){ CredentialDb db = new CredentialDb(context);//here CredentialDb is my database. you can create your db object. File exportDir = new File(Environment.getExternalStorageDirectory(), ""); if (!exportDir.exists()) { exportDir.mkdirs(); } File file = new File(exportDir, "csvfilename.csv"); try { file.createNewFile(); CSVWriter csvWrite = new CSVWriter(new FileWriter(file)); SQLiteDatabase sql_db = db.getReadableDatabase();//here create a method ,and return SQLiteDatabaseObject.getReadableDatabase(); Cursor curCSV = sql_db.rawQuery("SELECT * FROM "+CredentialDb.TABLE_NAME,null); csvWrite.writeNext(curCSV.getColumnNames()); while(curCSV.moveToNext()) { //Which column you want to export you can add over here... String arrStr[] ={curCSV.getString(0),curCSV.getString(1), curCSV.getString(2)}; csvWrite.writeNext(arrStr); } csvWrite.close(); curCSV.close(); } catch(Exception sqlEx) { Log.e("Error:", sqlEx.getMessage(), sqlEx); } } }