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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:43:25+00:00 2026-06-07T06:43:25+00:00

Wow, I cant believe how many problems related to loading and saving to internal

  • 0

Wow, I cant believe how many problems related to loading and saving to internal memory.
I find that I can only Save to a protected area related to my app.
I am not sure I can even create a directory in that area.
Storing to the SD I’ve mastered, but the requirements are that if no sdcard is available or has been removed the app continues be able to load and save user settings. I have 120 different data items so shared preferences are not the way. Cache is not persistent.

I currently have as a method :

public static void SaveUserPrefs()
{
 try
{
 //FileOutputStream fos = openFileOutput("userPrefs.dat", Context.MODE_PRIVATE);
 FileOutputStream fos = new FileOutputStream( "userPrefs.dat"); 
 BufferedOutputStream bos = new BufferedOutputStream(fos); //to get a buffered stream  
 ObjectOutputStream oos = new ObjectOutputStream(bos);
 oos.writeFloat(versionNumber);
 oos.writeInt(autoWifiStart);
 oos.writeInt(autoAirPlane);
 ... many more items and file close

I get file not found exceptiom /userPrefs.dat Read only file system
You would think the same code would work either external or internal, but doesnt.
I have tried the comment out code also with same results.
Where and how do I save this data?
And do I need to do something different to load it?
I do have permission set to save_external_Storage.

  • 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-07T06:43:26+00:00Added an answer on June 7, 2026 at 6:43 am

    I find that I can only Save to a protected area related to my app.

    On internal storage, this is correct.

    I am not sure I can even create a directory in that area.

    Use getFilesDir() to retrieve a File object pointing to your application’s area on internal storage, then call mkdirs() on the File object to create subdirectories. The latter is standard Java file I/O.

    I have 120 different data items so shared preferences are not the way.

    There is no particular limit on the number of items in SharedPreferences. SharedPreferences are stored in an XML file.

    I get file not found exceptiom /userPrefs.dat Read only file system

    You have supplied an invalid path. Use getFilesDir() to get the File object pointing to your application’s area on internal storage, then use the appropriate File constructor to create a File object pointing to your specific file on internal storage. Use that latter File object in your FileOutputStream constructor. Again, other than getFilesDir(), this is standard Java file I/O.

    You would think the same code would work either external or internal, but doesnt

    That code does not work with external storage, either, as the path you have supplied is not on external storage.

    Where and how do I save this data?

    Personally, I would never use ObjectOutputStream. For 120 items, I would definitely consider a SQLite database, otherwise I would serialize my data to JSON or XML. Any of those options are easier to debug than ObjectOutputStream, IMHO.

    And do I need to do something different to load it?

    You will need to construct the appropriate File object pointing to the file in question for use with some type of InputStream, following standard Java file I/O.

    I do have permission set to save_external_Storage.

    WRITE_EXTERNAL_STORAGE is not necessary for writing to internal storage.

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

Sidebar

Related Questions

wow , i just can't find any working httpclient 4.1 example , to send
WOW! That's a weird title, but I'm happy you're looking, cause I couldn't find
// Edit: oh wow. It's odd that I've been working on this for a
It's really simple, I just want one screen. Wow, that [shiny thing] must have
I'm sure this has been asked but I can't quite find the right search
Wow, I've never really used symlinks that much before, but this is really boggling:
Wow, this one is though! I'm trying to find in PHP the % of
How do I make a form that can log into two places simultaneously? http://img577.imageshack.us/img577/3127/calendarlogin.jpg
This is a WoW (World of Warcraft) lua script question. Not many of these
Wow, this seems so basic, but I can't get it to work. All I

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.