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 8227375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:06:37+00:00 2026-06-07T16:06:37+00:00

I am trying to develop apps for Android and I don’t know how to

  • 0

I am trying to develop apps for Android and I don’t know how to write/read a file in Android phone.

Normally I would do the following:

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class Test {

    public static void main(String[] args) {
        try {
            String path = "file.txt";
            BufferedWriter bw = new BufferedWriter(new FileWriter(path));
            bw.write("XYZ");
            bw.close();

            BufferedReader br = new BufferedReader(new FileReader(path));
            String line = "", data = "";
            while ((line = br.readLine()) != null) {
                data = data + line;
            }
            br.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
  • 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-06-07T16:06:40+00:00Added an answer on June 7, 2026 at 4:06 pm

    You’re pretty close. Here is something that I did, where I check to see if there is an SD card, if not it will save it locally (remember, since it is an Android app, all your data will be saved on the phone), then you create a directory if there isn’t one and then write to file. Let me know if you have any questions. This is more for writing, but reading is just as simple, you simply create a buffered reader, give it the file, and read; much like you have done in your code.

    I hope this helps:

    SimpleDateFormat photoFormat = new SimpleDateFormat("ddMMyy-hhmmss");
    
            // create formating for date
            SimpleDateFormat sdf = new SimpleDateFormat("MMMddyy-hhmmss");
            /*
             * This sections checks the phone to see if there is a SD card. if
             * there is an SD card, a directory is created on the SD card to
             * store the test log results. If there is not a SD card, then the
             * directory is created on the phones internal hard drive
             */
            // if there is no SD card
            if (Environment.getExternalStorageState() == null) {
                directory = new File(Environment.getDataDirectory()
                        + "/RobotiumTestLog/");
                photoDirectory = new File(Environment.getDataDirectory()
                        + "/Robotium-Screenshots/");
    
                // if no directory exists, create new directory
                if (!directory.exists()) {
                    directory.mkdir();
                }
    
                // if phone DOES have sd card
            } else if (Environment.getExternalStorageState() != null) {
                // search for directory on SD card
                directory = new File(Environment.getExternalStorageDirectory()
                        + "/RobotiumTestLog/");
                photoDirectory = new File(
                        Environment.getExternalStorageDirectory()
                                + "/Robotium-Screenshots/");
    
                // if no directory exists, create new directory to store test
                // results
                if (!directory.exists()) {
                    directory.mkdir();
                }
            }// end of SD card checking
    
            /*
             * Below is where the name of the test log is created.This can be
             * changed for any other test methods
             */
            String fileName = "TravelTestResults.csv";
    
            /*
             * Checks for existing test logs, and if they exist, they are
             * deleted, creating a new test log for each testing method
             */
            File logResults = new File(directory, fileName);
            if (logResults.exists()) {
                logResults.delete();
            }
            if (!logResults.exists()) {
                logResults.createNewFile();
            }
            /*
             * This creates the writing stream to log the test results This
             * stream MUST be closed, using bw.close(), for the test results to
             * show on the log. If the stream is not closed, when you open the
             * text file that the results are stored in, the page will be blank.
             */
            bw = new BufferedWriter(new FileWriter(logResults, true));
            bw.write("Test Run, Test Result, Comments \"\n\"");
                        bw.close(); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to develop android web apps using html 5.I'm using dreamviewer 5 with
I am trying to develop android apps on a MAC Mini and have installed
First off I'm new to owning an android and trying to develop android apps.
I am trying to learn to develop Android apps. I followed the steps at
i am trying to develop a remote desktop apps with c#. so i have
I'm trying to develop a module for Drupal, I'm quite new. The following piece
I am new to iPhone apps development. I am trying to develop a small
I am trying develop an Android app which uses Google maps. So for the
I am beginner and trying to develop facebook desktop apps with below code use
Okay, well I am trying to learn how to develop mac apps. I have

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.