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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:54:04+00:00 2026-05-31T16:54:04+00:00

I need to store this object into the internal storage memory of the phone,

  • 0

I need to store this object into the internal storage memory of the phone, and i have the <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE"></uses-permission> set on the manifest. The object itself haves two static methods for store and reload it from the internal memory:

public class SaveState implements Serializable {
static public List<FullMagazine> fms = new ArrayList<FullMagazine>();
static SaveState instance=null;

public static SaveState getInstance(){      
    if( instance == null )
        instance = new SaveState();     
    return instance;
}

public static void saveData(SaveState instance){
    ObjectOutput out;
    try {
        out = new ObjectOutputStream(new FileOutputStream("appSaveState.data"));        
        out.writeObject(instance);
        out.close();
    } catch (Exception e) {e.printStackTrace();}
}

public static SaveState loadData(){
    ObjectInput in;
    SaveState ss=null;
    try {
        in = new ObjectInputStream(new FileInputStream("appSaveState.data"));       
        ss=(SaveState) in.readObject();
        in.close();
    } catch (Exception e) {e.printStackTrace();}
    return ss;
}
}

I’m trying to store it and reopen it using this call in my activity:

            SaveState.fms.add(fm);
            SaveState.saveData(SaveState.getInstance());                
            SaveState sv = SaveState.loadData();

But it is not working, it is not storing the object, and ofcourse it is not reading the objecto, i’m getting these two exception while storing and reading the object:

    03-23 09:18:16.702: WARN/System.err(9060): java.io.FileNotFoundException: /appSaveState.data (Read-only file system)
03-23 09:18:16.702: WARN/System.err(9060):     at org.apache.harmony.luni.platform.OSFileSystem.openImpl(Native Method)
03-23 09:18:16.702: WARN/System.err(9060):     at org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:152)
03-23 09:18:16.702: WARN/System.err(9060):     at java.io.FileOutputStream.<init>(FileOutputStream.java:97)
03-23 09:18:16.702: WARN/System.err(9060):     at java.io.FileOutputStream.<init>(FileOutputStream.java:168)
03-23 09:18:16.702: WARN/System.err(9060):     at java.io.FileOutputStream.<init>(FileOutputStream.java:147)
03-23 09:18:16.702: WARN/System.err(9060):     at com.Magazine.SaveState.saveData(SaveState.java:35)
03-23 09:18:16.702: WARN/System.err(9060):     at com.Magazine.MainMenu$DownloadThread.run(MainMenu.java:807)
03-23 09:18:16.709: WARN/System.err(9060): java.io.FileNotFoundException: /appSaveState.data (No such file or directory)
03-23 09:18:16.709: WARN/System.err(9060):     at org.apache.harmony.luni.platform.OSFileSystem.openImpl(Native Method)
03-23 09:18:16.709: WARN/System.err(9060):     at org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:152)
03-23 09:18:16.709: WARN/System.err(9060):     at java.io.FileInputStream.<init>(FileInputStream.java:82)
03-23 09:18:16.709: WARN/System.err(9060):     at java.io.FileInputStream.<init>(FileInputStream.java:134)
03-23 09:18:16.709: WARN/System.err(9060):     at com.Magazine.SaveState.loadData(SaveState.java:46)
03-23 09:18:16.709: WARN/System.err(9060):     at com.Magazine.MainMenu$DownloadThread.run(MainMenu.java:809)

What’s wrong in the code?

Thanks

  • 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-31T16:54:06+00:00Added an answer on May 31, 2026 at 4:54 pm

    change this

    out = new ObjectOutputStream(new FileOutputStream("appSaveState.data"));
    

    with

       File outFile = new File(Environment.getExternalStorageDirectory(), "appSaveState.data");
       out = new ObjectOutputStream(new FileOutputStream(outFile)); 
    

    as correctly pointed out by @e-x, the file will not be removed clearing application’s data or uninstalling the app

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

Sidebar

Related Questions

Basically, I need to store past versions of this object in its current state
I need to store the type of an object in a class. This would
User Story: Action for Facebook that has open graph object. For this I need
I have a scenario like this: I need to pass @id to the stored
I have id values for products that I need store. Right now they are
I have an object handed into our library and passed through various processes. I
I'm using rails 3.2 and Ruby 1.9.3 I have a need to store data
We need to extract and store C# objects into Apache Solr but weren't sure
I'm trying to do something simple and store an object into an Array in
Here's the situation: I have a massive object that needs to be loaded into

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.