0

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.

edwoollard
  • 12,245
  • 6
  • 43
  • 74
  • Have you checked [this](http://stackoverflow.com/questions/2887119/populate-android-database-from-csv-file) – Emmanuel N Jan 19 '12 at 16:34

2 Answers2

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

Try the following : tutorial

kosa
  • 65,990
  • 13
  • 130
  • 167
Viking
  • 882
  • 10
  • 16
  • 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