Save local CSV file

Hi, I am using BASIC to create a Phonegap Android App to collect data onto SQLite. At the end of the program, I need to click a button to save all the data from SQLite to local CSV file and then transfer to window using a USB communication cable. Should I need to use cordova plugin? Any sample code? If I am using web app instead of Phonegap, is it possible?

You can write out a file using the cordova-plugin-file PhoneGap Plugin:

That being said, data is not usually transferred to servers as files. The usual way to do this is to send the data using Ajax:
https://wiki.appstudio.dev/Ajax_made_Simple