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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:37:31+00:00 2026-06-08T16:37:31+00:00

i want to open a file that i create in android and allways give

  • 0

i want to open a file that i create in android and allways give me this error, the main problem is when i want to open the file, that the app crash

07-29 14:56:09.708: E/AndroidRuntime(577): java.lang.IllegalStateException: Could not execute method of the activity
07-29 14:56:09.708: E/AndroidRuntime(577):  at android.os.Handler.dispatchMessage(Handler.java:92)
07-29 14:56:09.708: E/AndroidRuntime(577):  at java.lang.reflect.Method.invokeNative(Native Method)
07-29 14:56:09.708: E/AndroidRuntime(577):  at java.lang.reflect.Method.invoke(Method.java:511)
07-29 14:56:09.708: E/AndroidRuntime(577):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-29 14:56:09.708: E/AndroidRuntime(577):  at dalvik.system.NativeStart.main(Native Method)
07-29 14:56:09.708: E/AndroidRuntime(577):  at java.lang.reflect.Method.invokeNative(Native Method)
07-29 14:56:09.708: E/AndroidRuntime(577):  at java.lang.reflect.Method.invoke(Method.java:511)
07-29 14:56:09.708: E/AndroidRuntime(577):  at menu.menuapp.FrontActivity.confirm(FrontActivity.java:51)
07-29 14:56:09.708: E/AndroidRuntime(577):  at libcore.io.Posix.open(Native Method)

This is the code to save the file.

//Opening the notes file to be write.
    String notes_str = "<resource></resource>"
FileOutputStream notes_file = openFileOutput("notes.xml", Context.MODE_PRIVATE);

//Converting to string the notes_doc
String notes_str = new menu.menuapp.general().xmltostring(notes_doc);
//Saving on the file
notes_file.write(notes_str.getBytes());
//Closing the file.
notes_file.close();

This is the code to open the file.

File file = new File("notes.xml");
FileInputStream notes_xml = new FileInputStream(file);
byte fileContent[] = new byte[(int)notes_xml.available()];
//The information will be content on the buffer.

notes_xml.read(fileContent);

String strContent = new String(fileContent);
    notes_xml.close();
  • 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-08T16:37:32+00:00Added an answer on June 8, 2026 at 4:37 pm

    You are not specifying the path correctly when you open the file for read. The constructor you use for File requires a full path, not just a file name.

    If you write the file with openFileOutput(), then I suggest you read it back with openFileInput(). That way you’re more likely to get all the parameters right.

    For more guidance on reading and writing files, see here: http://developer.android.com/guide/topics/data/data-storage.html#filesInternal

    Also, your filename is different when reading and writing. You should define that in a string resource or at least a static final.

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

Sidebar

Related Questions

In my app, I open the camera and want to save that file with
I want to create IFile interface to open file that locate outside project or
I want to open file and read it that I pass from console. Like
I have a .mat file that I want to open and see its contents.
I want to write a php script that keeps the apache_log file open and
What I want open a file if it exists, create it if it not
I want to open a file for reading. However, in the context of this
I have a file that I'm working with. I want to create a function
I create a txt file that have 3 element and i wrote this code
I want to: open a file in read-write mode if it exists; create 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.