Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6614621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:21:39+00:00 2026-05-25T20:21:39+00:00

I am writing an Android App that collects data as a String of comma-separated-values

  • 0

I am writing an Android App that collects data as a String of comma-separated-values (terminating each line with ‘\n’) and then emails me the data once a month.

One of my beta-testers has informed me that he would like to be able to view the intermediate data between uploads. The natural way to do this (to my mind) would be to load the data to an “excel-like” app (such as QuickOffice or google doc’s viewer). I tried writing the String out to a file and then loading it into QuickOffice. I can get QuickOffice to launch, but the file comes up blank. Also, when I look for the file on my SD card, I can’t find it.

My code:

File root = Environment.getExternalStorageDirectory();
try
{
    BufferedWriter out = new BufferedWriter(new FileWriter(root.toString() + "/ww.csv"));
    out.write(getPreferences(MODE_PRIVATE).getString("allTrips", ""));
    out.flush();  // Probably not necessary
    out.close();
}
catch (IOException e)
{
    // TODO Auto-generated catch block
    e.printStackTrace();
}

Intent i1 = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.fromFile(new File(root.toString() + "/ww.csv"));
i1.setDataAndType(data, "application/vnd.ms-excel");
startActivity(i1);

Please let me know what I’m doing wrong. I’m open to small tweaks to my code above, as well as completely different approaches that get the job done.

Before you ask, I remembered to add

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

to my manifest.

Also, I’m as happy to write to the Internal File System instead of the SD card (my data are small) but I couldn’t get that to even open QuickOffice.

An example of the data:

09/19/2011,AP2,Home,GW Parkway,12:03 PM,12:41 PM,38,Dry,Day
09/20/2011,Home,AP2,MacArthur Blvd,7:18 AM,8:32 AM,74,Rain,Day
09/20/2011,AP2,Home,Rock Creek Pkwy (Blagden),4:51 PM,5:45 PM,54,Dry,Day
09/21/2011,Home,AP2,Rte 295,6:44 AM,7:36 AM,52,Rain,Day

Thanks.

UPDATE (OCT 09 2011):

Sometimes when writing code, you need to take a step back and rethink what you’re trying to accomplish. All I want to do is reformat my interim data and make an easy-to-read table to the user can see the data in-between monthly uploads. I thought the easiest way to do this would be to load my .csv file into a spreadsheet. Nikolay’s suggestion of using an outside library to ensure that my file was properly formatted might have worked, but I’m trying to keep this app as lean as possible, so I want to avoid using (and learning to use) external libraries unnecessarily. So, my end solution has been to write a slightly larger file to the SD card using html format and then opening the file as text/html rather than text/plain or application/vnd.ms-excel. That took about an hour of coding and has solved the issue nicely, so I’m going to consider the problem closed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:21:40+00:00Added an answer on May 25, 2026 at 8:21 pm

    At least part of the problem is file format. When I change “application/vnd.ms-excel” to “text/plain” I am able to open the data in a text file. This is less than ideal, because it’s harder to read than if it opened in a spreadsheet.

    I’ll keep looking for a better answer.

    UPDATE (OCT 09 2011):

    In the end, my better answer was “Use HTML table as a work-around”. It turned out to be the path of least resistance. See my updated question for a longer explanation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm planning on writing an android app that can view and update data on
I am writing an android app that recieves data over bluetooth. The bytes comming
I'm currently writing an app in Android that works with the GPS. At the
I am writing an android app. I want to pass some data across the
I'm writing an Android app that contains a contact list. The design required me
I'm writing an android app that has a spinner in it for difficulty settings
I am looking into writing an Android app that has a database of approximately
I am considering writing an Android app, and I see that the SDK is
I'm writing an Android app that is parsing RSS feeds from different sources. What
I am writing an android app that is communicating with a webserver to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.