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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:08:04+00:00 2026-05-26T01:08:04+00:00

I am having some issues with writing and reading with android. here is my

  • 0

I am having some issues with writing and reading with android.
here is my code:

package filereader.testing.com;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class FileReaderTestingActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button submit_btn =  (Button) findViewById (R.id.submit_btn);
        final EditText textbox = (EditText) findViewById (R.id.first_text);
        final TextView newtext = (TextView) findViewById (R.id.read_text);
        submit_btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                    byte[] readinfo = new byte[3];
                    String FILENAME = "first_file";
                FileOutputStream mystream;
            try {
                mystream = openFileOutput (FILENAME, Context.MODE_PRIVATE);
                String variabletowrite = textbox.toString();
                mystream.write(variabletowrite.getBytes());
                mystream.close();
                FileInputStream readstream = openFileInput (FILENAME);
                readstream.read(readinfo);
                newtext.setText(readinfo.toString());
                readstream.close();
            } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            }
            }
        });
    }
}

the try and catch was added by eclipse

here is my xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="1">
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
/>
<EditText android:id="@+id/first_text" android:layout_width="match_parent"       
android:layout_height="wrap_content">
<requestFocus></requestFocus>
</EditText>
<Button android:layout_height="wrap_content" android:text="Submit"     
android:id="@+id/submit_btn" android:layout_width="match_parent"></Button>
<TextView android:textAppearance="?android:attr/textAppearanceLarge"     android:layout_height="wrap_content" android:text="TextView" android:id="@+id/read_text" android:layout_weight="0.12" android:layout_width="280dp"></TextView>
</LinearLayout>

and here is my manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="filereader.testing.com"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />

<application android:icon="@drawable/icon" android:label="@string/app_name" android:permission="android.permission.WRITE_EXTERNAL_STORAGE">
    <activity android:name=".FileReaderTestingActivity"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>
</manifest>

when I run the code all of the text boxes appear and so does the submit button, but when I type something in and then hit the submit button the text box changes to things like [B@40532d08 and I have no idea what it means. the number seems to count up every time that I click the submit button and the [B@ part never changes, just the numbers and letters after it.

any help would be greatly appreciated, thank you.

  • 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-26T01:08:05+00:00Added an answer on May 26, 2026 at 1:08 am

    Change this line…

    String variabletowrite = textbox.toString();
    

    to…

    String variabletowrite = textbox.getText().toString();
    

    The first line (the way you are doing it) is calling toString() on the EditText object itself (i.e., it’s reference) and not its text contents.

    EDIT
    When setting the text for the TextView this line…

    newtext.setText(readinfo.toString());
    

    is also simply converting your byte[] reference to a string. You need to do something like the following to create a string from an array of bytes…

    newtext.setText(new String(readinfo));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Rrom C#, reading/writing over SOCKET to JAVA and having some concurrency/socket issue. I am
This might be a simple answer, but I am having some issues writing this
I am having some issues trying to convert a double to C++ string. Here
I am having some issues with a program I am writing in C, and
I am writing some code to solve thread-safe issues in a system am working
Ok, So I'm writing a task organizer script and I'm having some issues with
Having some issues getting my head around the differences between UTF-8, UTF-16, ASCII and
Having some issues with the ... in ObjectiveC. I'm basically wrapping a method and
We've been having some issues with a SharePoint instance in a test environment. Thankfully
I have been having some issues with LINQ-To-SQL around memory usage. I'm using it

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.