File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes csv file is not created Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "csv file is not created" Watch "csv file is not created" New topic
Author

csv file is not created

sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
I need to create the CSV file using my android application.So i uses Opencsv library to create CSV file.Below is my code



i called this method in my android class.below is my code for that.but it doesn't create any files in C drive.where is the error.I ran the application emulatoor.not the real phone?

Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4165
    
  21

Files created in an emulator will not be stored on the host's file system. There is a virtual disk used by the emulator for the internal storage and possible a second one used for the sd card. You will need to use apps in the emulator to find the file or use adp to explore the phone's file system.


Steve
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4165
    
  21

You should also read the log cat output to see if there are any reputed errors. I suspect there will be.
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
i debug the code.then i got below exception.



i got above exception in below line


why i am getting exception on that line?


below is logcat output

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30068
    
149

I wouldn't expect Android to have a c: drive. That's a Windows thing.

Take a look at the Android file storage page. For writing to an external directory, it shows code like this:


On my genymotion emulator the File directory was: /storage/emulated/0/Pictures

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
i change the my class as below



Still i am getting Permission denied on below line


i have already added the below lines to manifest file


sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
can anyone tell me whhy it gives me permission error?
Irina Goble
Ranch Hand

Joined: May 09, 2004
Posts: 91
Can you show the error message?
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
this is the method for creating file




below is i am getting in LogCat file

sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
hi Irina/All

can anyone please help me to do this ?
Irina Goble
Ranch Hand

Joined: May 09, 2004
Posts: 91
Do you check if the media is available? Here is a code snippet from the link that Jeanne gave you.
Plus it will be helpful if you print the full file name.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41065
    
  43
In addition to checking state, note the paragraph starting with "Applications should not directly use this top-level directory,..." in the javadocs. That's effectively what you're doing, so you should fix that.


Ping & DNS - my free Android networking tools app
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
now its working fine.anyway i have one issue still.I need to write String array as a currently when i used below code it writes data as a row.how to change it to write as a column.

Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4165
    
  21

Have you read the API for the CSVWriter you are using?

Before you start coding, you should clearly define exactly what you want to do. Then you should read the API to see how it works. Then you should describe the steps (to yourself, in your native language, and on paper) needed to get what you want to a form the API expects. Then you should write code. This does mean a few things you need practice on:
1) Reading documentation
2) Thinking ahead

I am pretty sure if you do the simple thing and take just the code you have and print it out into a column instead of a row you will then have problems getting the rest of your data to match up to the row you need it to. So you need to understand the API, how it works, and what you need to do before you start coding.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: csv file is not created
 
Similar Threads
Creating CSV file in java
Printing a line of array fields
Passing FileReader an alternative to a file
Problem creating CSV file with writeAll method of CSVWriter
Copy name of file from input to output