How to open csv file in Android - android

I am new to Android. I've created a .csv file in SD card. Now I want to open this file but unable to do this.
Please help me on how to open a .csv file.

You can open a .csv file like you would any text file. In order to read it, look for some examples in java - like Parse CSV File using StringTokenizer example

http://code.google.com/p/secrets-for-android/source/browse/trunk/src/au/com/bytecode/opencsv/CSVReader.java?r=19
This could parse a csv file

I posted some example code here: How to parse the CSV file in android application?
You would obviously have to change it slightly to access a file on the sdcard and not in the assets folder.

Related

Keeping a text file in android

I am new to android and facing issue with file system usages.
I have seen several threads but i am still not able to find the answer which i am looking for my requirement.
I have a original file say test.xml which i want to keep somewhere in my eclipse project so that as soon as i install the app it should move my test.xml file into data directory so that i would be able to read it
please refere this link :
http://developer.android.com/training/basics/data-storage/files.html
I want to save my original file at : "/data/data/com.example.helloWorld/files"
I should be able to get the file handle form the below command
File file = new File(context.getFilesDir(), filename);
Please Note i dont want to save my file in asset folder.
Thanks,
Manish Bansal
I recommend you use assets as storage for your file initially as that will get compiled with your app, then once the user starts your app you check if your file exists and if not you can save the asset to the internal storage location as specified in the documentation, from there you can use the file as you like in the filesystem.

Read Excel file in android

Im developing an android App I want to read the data in from Excel File Anyone having Idea How to read Excel file in android. I keep my file in res/raw folder and try to read it as given in this tutorial http://www.vogella.de/articles/JavaExcel/article.html Its not working if anyone having Idea then Reply Please
Thank you
Abhishek
Try using Apache POI
Also, see this related question
You could try out jexcelapi (http://jexcelapi.sourceforge.net/) or apache poi (http://poi.apache.org/).
Keep the file in the SDcard and give the path of the SDCArd while reading the file
File sdCard = Environment.getExternalStorageDirectory();
File dir = new File(sdCard.getAbsolutePath() + "/Excel/filename.xls");
For eg. if you are keeping the file in excel folder then give the path as above

Get a xml file from sdcard to android app?

I need to save a xml file from sdcard to my android app, in res/values. How can I do this? Can anyone help me?
just use the java file command for your xml file on sdcard.
File file=new File("/mnt/sdcard/example.xml");
and using DOM or SAX parser you can parse the data(information) from it for your application.
Thnx.
EDIT: parsing local xml file using Sax in android, Read XML Resources in Android, using XmlResourceParser: XML parsing interface or Here or Here Look at these tutorials.
They are just folders in an Android project when you develop. When the app is compiled, everything in src and res is turned into binary code, and packed in one apk. Therefore I don't think that you will have res folder or anything like that in the device.

Get filename of file from web directory

I'm trying to simply get the filename of a file from an online directory. The directory only has one file in it. The filename is actually the version number. If the filename is "newer" than the file that I already have stored on the android, it will download the file and replace it. I already know how to download the file. I'm not sure if android has some sort of built-in directory lister or if I need to create a PHP file that will display the files, then somehow open and read that in and use that as my path. Any help would be greatly appreciated.
You'll want to write that PHP script to return the file name. With that, you can do a straight download from the server.

How to write to a file saved in local folder in Android

I am having a file in the folder res/raw/a.xml.
I want to write some data to this file?
How it can be done in Android?
How can we access a file stored in local directory in order to write data to that file.
can anyone help me in sorting out this issue ?
Thanks in Advance,
Hi, I am having a file in the folder res/raw/a.xml. I want to write some data to this file? How it can be done in Android?
You cannot modify a resource at runtime, sorry.
How can we access a file stored in local directory in order to write data to that file.
Use getFilesDir() to get a File object pointing to your app's local directory. Then, use standard Java I/O.

Categories

Resources