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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:28:32+00:00 2026-05-25T20:28:32+00:00

All right, i’m reading a lot about the saving and accessing implementations in various

  • 0

All right, i’m reading a lot about the saving and accessing implementations in various Android and off-site documentations/help sites, but i still can’t understand the implementation and how does it work, so my last resort is to turn to StackOverFlow (i’m working on this on my own)

I’m going to sound a bit daft and retarded at times in this question because i’m learning on-the-fly whilst making my application, so bear with me (and i’ve labelled out parts of the entire document where i have questions):

First off, i see that to implement a saved file, one has to write (as taken from android docs):

//Declarations
String FILENAME = "hello_file";
String string = "hello world!";

//Meaning that FILENAME is to be saved as hello_file, and "hello world!" converts the string to bytes
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();

inside whichever function that saves the data (example a button) inside, like this:

public void testButtonPressToSave() {

FileOutputStream testSaveFile = openFileOutput(SavedFile, Context.MODE_PRIVATE);
testSaveFile.write();
testSaveFile.close();

}

However, when i implement it into the code, Eclipse recommends me to use a try/catch exception in the openFileOutput part, and the entire thing changes to:

public void testButtonPressToSave() {
    FileOutputStream testSaveFile;
try {
    testSaveFile = openFileOutput(SavedFile, Context.MODE_PRIVATE);
} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
try {
    testSaveFile.write(testString.getBytes());
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
try {
    testSaveFile.close();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
}

(QUESTION) Is this normal? How am i able to reuse my saved file if it is on another activity? Do i import the entire main activity into the, say, a widget provider class?

Also, I fully understand that:

1)  FileOutputStream testSaveFile; and testSaveFile = openFileOutput(SavedFile, Context.MODE_PRIVATE);

Declares testSaveFile as a FileOutputStream object and that it saves a file (.txt?) using a Context.MODE_PRIVATE which limits the file to only being able to be accessed by the application itself.

and,

2)  testSaveFile.close(); 

Ends the stream, somehow (but this is pretty direct, it just closes the file)

The part i don’t really get is, how do i save multiple variables inside the SavedFile data package?

The Android documentation provides me with the available write() functions under FileOutputStream:

public void write (byte[] buffer, int offset, int byteCount)

public void write (byte[] buffer)

public void write (int oneByte)

Which isnt exactly what i want, because i need the stream to save multiple variables such as a String and Integer[].

(QUESTION) How do i go about saving my desired data types into the SavedFile?

I’ve also read about Serialization, but i’m unsure how it would actually work to save a file into my application. Also, i’m not very confident that Serialization would be very efficient on a Dalvik VM (Android) because most of the code i’ve read and gone through are based on Java systems.

There was also a Bundle android resource thingy that i don’t understand but seems like the answer to store various multiple variables into one package and then unpackaging them at the next activity, although i don’t see how i am able to actually save it into a file or something.

Alright, i’m blabbing away with a lot of points but i’d be very grateful if anyone would be able to answer these questions. You don’t have to provide an answer, but a clear explanation would be very much appreciated (especially around technical jargons :S)

  • 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-25T20:28:32+00:00Added an answer on May 25, 2026 at 8:28 pm

    Looks like i’ve found a more effective way to store my data, through SQLiteDatabase in Android. Thanks anyway!

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

Sidebar

Related Questions

All right all, So I've got a UITableView that is inited in applicationDidFinishLaunching like
I'm using the OnIdle-event for some simple animations, and it works all right. The
you all know: right click -> zoom in or out in flash file, well,
Right now all of my times on my reports are in GMT. Anybody know
Right now all I am using to calculate the size are the files in
The idea is to move all of the right elements into the left and
I'm developing a facebook app right now all by my lonesome. I'm attempting to
The WebBrowser control has a property called IsWebBrowserContextMenuEnabled that disables all ability to right-click
All members are camel case, right? Why True/False but not true/false, which is more
right now i am simply ftping everything (all of my source code included) but

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.