I was wondering whether anyone had the code that would allow me to export my database in my app and export it as a .csv. This would then hopefully allow people to open it in Microsoft Office Excel and read their data at any time.
Asked
Active
Viewed 1,427 times
0
-
Have you checked [this](http://stackoverflow.com/questions/2887119/populate-android-database-from-csv-file) – Emmanuel N Jan 19 '12 at 16:34
2 Answers
3
just do SELECT * FROM [table]; (into some datastructure)
FileWriter fstream = new FileWriter("out.txt");
BufferedWriter out = new BufferedWriter(fstream);
for(y=0; y<=[#rows]; y++){
for(x=0; x<=[#columns]; x++){
out.write([field]);
out.write(",");
}
out.write("\n");
}
out.close;

braden
- 1,496
- 17
- 31
2
-
Thanks very much. I think I can get this to work. I'll give you feedback at a later date when I have it correct. – edwoollard Jan 19 '12 at 16:42