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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:17:19+00:00 2026-05-24T06:17:19+00:00

I am trying to write to an existing XML file in the /res/xml directory

  • 0

I am trying to write to an existing XML file in the /res/xml directory on an Android device. Two questions:

1) Are these files able to be overwritten?
2) If so, how can I obtain a handle to that file?

I am trying this to no avail:

    FileOutputStream fos;

    try {
        fos = openFileOutput("/res/xml/scores.xml", Context.MODE_PRIVATE);
        fos.write(writer.toString().getBytes());
        fos.close();
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

UPDATE

Trying to read from the file using:

....
        PriorityQueue<Score> scores = new PriorityQueue<Score>();
    XmlPullParserFactory xmlFac = XmlPullParserFactory.newInstance();
    XmlPullParser qXML = xmlFac.newPullParser();
    File scoresFile = new File(c.getExternalFilesDir(null), "scores.xml");
    InputStream is = new FileInputStream(scoresFile);
    qXML.setInput(is,null);
....

Trying to write to the file using:

....
    File scoresFile = new File(getExternalFilesDir(null), "scores.xml");
    OutputStream os = new FileOutputStream(scoresFile);

    os.write(writer.toString().getBytes());
    os.flush();
    os.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-05-24T06:17:19+00:00Added an answer on May 24, 2026 at 6:17 am

    You need to use the external storage on the device. You can’t and shouldn’t be writing to the resources. Instead, copy the resource to the external storage, and then modify it there.

    EDIT: You can also use your application’s internal data folder to save files to, but again, you will want to copy your resource there if you want to modify it. This will allow the files to remain internal to your application.

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

Sidebar

Related Questions

I am trying to write an Android app to connect to an existing web
I'm Trying to Write Logs to Custom Log.txt File on Android File using this
I am trying to extract RDF triples from XML files by using an existing
I am trying to write XML Schema by existing XML format description (i.e. document
There is an existing xml file & xsd . as i want to write
I am trying to write a build.xml file for my project. When I run
I'm trying to write (or just find an existing) PHP method that can take
Trying to write a couple of functions that will encrypt or decrypt a file
Im trying to write a single byte at a certain location in a file.
I'm trying to add a processing instruction node to an existing XML document to

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.