6

I am developing android app where SQlite as a database.I want to export my android app database in to excel file format programmatically, so that normal people can read their database easily.If it is possible than please give me hint or not than help me to convert any other file format like text file or other. thanks for voting...

Montia
  • 35
  • 1
  • 8
Mohit Raval
  • 440
  • 1
  • 6
  • 19

1 Answers1

7

Excel reads CSV, so this would by far be your easiest option. Have a look at opencsv

http://opencsv.sourceforge.net

it contains pretty much everything you need. The process becomes as simple as:

  1. read the data you wish to export from Sqlite.
  2. write the results into a csv file (remember to name it *something***.csv**, so excel will know its a csv file)

and thats it really :)

EDIT: Based on your comments below, I suggest you take a look at this thread

How can I use external JARs in an Android project?

EDIT for gradle dependencies

Add compile 'com.opencsv:opencsv:4.1' to app gradle. That's it. No need to add jars.

Reference: http://opencsv.sourceforge.net/dependency-info.html

Karan
  • 83
  • 7
JustDanyul
  • 13,813
  • 7
  • 53
  • 71
  • i got this error in CSVWriter function "java.lang.NoClassDefFoundError: au.com.bytecode.opencsv.CSVWriter" – Mohit Raval Oct 26 '12 at 07:06
  • (http://stackoverflow.com/questions/8724866/how-to-convert-data-base-records-into-csv-file-in-android) I am working on this code. and got above error in this function CSVWriter csvWrite = new CSVWriter(new FileWriter(file)); please vote... thanks. – Mohit Raval Oct 26 '12 at 07:19
  • it can't find the CSVWriter class on the classpath. In other words, you haven't installed the library correctly. PS. you haven't accepted any answers on StackOverflow as of yet. People might loose interest in helping you out if you dont improve on this. – JustDanyul Oct 26 '12 at 08:37
  • ohh.. sorry for that. now accepted this one.. :) but in my application i download lib file javacsv and opencsv-1.6, and also include in my application. which is in reference lib. but after that again same error. i can't get any right solution for that. thanks again. – Mohit Raval Oct 26 '12 at 09:36