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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:47:42+00:00 2026-05-19T09:47:42+00:00

I just wanna create a text file into phone memory and have to read

  • 0

I just wanna create a text file into phone memory and have to read its content to display.Now i created a text file.But its not present in the path data/data/package-name/file name.txt & it didn’t display the content on emulator.

My code is..

public class PhonememAct extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv=(TextView)findViewById(R.id.tv);

        FileOutputStream fos = null;
        try {
            fos = openFileOutput("Test.txt", Context.MODE_PRIVATE);
        } catch (FileNotFoundException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        }
        try {
            fos.write("Hai..".getBytes());
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        try {
            fos.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


        FileInputStream fis = null;
        try {
            fis = openFileInput("Test.txt");
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        int c;

        try {
            while((c=fis.read())!=-1)
                    {
                        tv.setText(c);
                        setContentView(tv);

                        //k += (char)c;
                    }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

            try {
                fis.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }


    }
}

Thanks in adv.

  • 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-19T09:47:43+00:00Added an answer on May 19, 2026 at 9:47 am

    You don’t need to use input/output streams if you are simply trying to write/read text.

    Use FileWriter to write text to a file and BufferedReader to read text from a file – it’s much simpler. This works perfectly…

    try {
        File myDir = new File(getFilesDir().getAbsolutePath());
        String s = "";
    
        FileWriter fw = new FileWriter(myDir + "/Test.txt");
        fw.write("Hello World");
        fw.close();
    
        BufferedReader br = new BufferedReader(new FileReader(myDir + "/Test.txt"));
        s = br.readLine();
    
        // Set TextView text here using tv.setText(s);
    
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ı wanna create xml file on aspx.cs but ı have no idea what ı
I have created a installer with innosetup and i wanna use it to create
I just wanna to delete from specified text file first N characters, but i'm
I just wanna ask if there's a way in C#/ASP.NET to create 'dynamic' tables/fields
I am a new newbie to android. Just wanna know how could we create
I have a question but dont have a answer, i wanna create a application
So I have created a piece of software which I wanna package and post
I am an Android newbie and I wanna create a simple mp3 player. Now,
I'm using win32. I wanna create a hidden and undeletable file using CreateFile() if
The way we have to update our site now is to create a copy

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.