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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:52:23+00:00 2026-06-18T20:52:23+00:00

I am trying to Serialize an object in my application by using the Simple

  • 0

I am trying to Serialize an object in my application by using the Simple Xml Serialization.(http://simple.sourceforge.net/home.php). I am trying to serialize my person class but when I run it on my device I cannot find the xml file I have created. Please see my code below:

Person Class:

public class Person {

    public Person() {
    }

    public Person(String inFirstName, String inLastName) {
        SetFirstname(inFirstName);
        SetLastname(inLastName);
    }

    private String FirstName;

    public String GetFirstName() {
        return FirstName;
    }

    public void SetFirstname(String inFirstName) {
        FirstName = inFirstName;
    }

    private String LastName;

    public String GetLastName() {
        return LastName;
    }

    public void SetLastname(String inLastName) {
        LastName = inLastName;
    }

    @Override
    public boolean equals(Object inObject) {
        if (inObject instanceof Person) {
            Person inPerson = (Person) inObject;
            return this.FirstName.equalsIgnoreCase(inPerson.FirstName)
                    && this.LastName.equalsIgnoreCase(inPerson.LastName);
        }
        return false;
    }
}

Main Activity:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Person person1 = new Person("billy", "boontay");

        File xmlFile = new File(getFilesDir().getPath() + "/Person.xml");

        try {

            Serializer serializer = new Persister();

            serializer.write(person1, xmlFile);

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

}

Can anyone see where I am going wrong? And before anyone suggests it I have already added the write external storage permission to my manifest.

  • 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-18T20:52:24+00:00Added an answer on June 18, 2026 at 8:52 pm
    File xmlFile = new File(getFilesDir().getPath() + "/Person.xml");
    

    As I remember, the method getFilrsDir() will return the app folder path, which in data/data folder and you can only find it if you have rooted your device,
    try this:

    File xmlFile = new File(Environment.getExternalStorageDirectory().getPath() +  "/Person.xml");
    

    And may be you also need some annocate in your Person class:

    @root (name = "person") <br>
    public class Person {
    
        @Element (entry = "firstname")
        private String FirstName;
        @Element (entry = "lastname")
        private String LastName;
    
    }
    

    Hope this help.

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

Sidebar

Related Questions

I'm having some issues trying to serialize/deserialize a complex object graph using protobuf-net. I'm
I'm trying to serialize an object to XML that has a number of properties,
I've run into some problems when trying to serialize my object to XML. The
I have an XML file that I'm trying to serialize into an object. Some
I've been trying to serialize an XML (jQuery object) to string to POST it
I'm trying to serialize into a Xml File an object which is declared as
Rails: 3.0.3 Ruby: 1.9.2 Trying to deserialize a very simple object using YAML.load or
I'm trying to Serialize an object to a Byte array, for storage in a
I am trying to serialize a PagedList object ( https://github.com/martijnboland/MvcPaging/blob/master/src/MvcPaging/PagedList.cs ) to Json, like
I have been trying to serialize a pretty big object. This object uses dictionaries

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.