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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:52:32+00:00 2026-06-10T21:52:32+00:00

I have code that is inside my Activity class to load and save a

  • 0

I have code that is inside my Activity class to load and save a file. It works fine. The code saves the contents of cFavretClass. I’m trying to clean up the code, so I moved the file i/o into the cFavret Class.

I cannot get the code to compile. Now I get an error saying openFileOutput is undefined in type cFavrets.

I’m assuming that this method was declared in Googles Activity Class?
Does this mean all file I/O must be in the activity class?

boolean Save()
{
  String FILENAME = "hello_file";

  try {
    FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE );
    fos.write(buffer);
    fos.close();
  }
  // just catch all exceptions and return false
  catch (Throwable t) {
    return false;
  }       
  return true;
}  

boolean Load()
{
  String FILENAME = "hello_file";
  try {
    FileInputStream fos = openFileInput(FILENAME);   
    buffer[0]=0;
    fos.read(buffer);
    fos.close();
  }
  // just catch all exceptions and return false
  catch (Throwable t) {
  // maybe file does not exist, try creating it
    return false;
  }
  return true;
}
  • 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-10T21:52:33+00:00Added an answer on June 10, 2026 at 9:52 pm

    Does this mean all file I/O must be in the activity class?

    No, but the method in question is called from a context – just pass a context into the constructor of this cFavretClass (or to the method itself, if you prefer):

    Context mContext;
    public cFavretClass(Context context) {
      mContext = context;
    }
    
    ...
      // in your methods:
      mContext.openFileOutput(FILENAME);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one project inside that I have SqlServerFunctions in test.cs file. code: [Microsoft.SqlServer.Server.SqlFunction]
I have this activity that class a Login class inside an onclick event. My
I have the code that draw a point inside a polygon. Each time I
I have this code that shows all the images inside 'images' directory but it
I have a code that should get a LinearLayout (with more LinearLayout's inside), and
I have C# code that cycles through .sql files and executes what's inside them
I have a javascript code that have span tag and inside the span tag
Inside my .aspx I have some JSON code that looks like this: function someFunctionName()
I have this code snippet inside a function that checks if an object exists
I have some javascript and c# code inside one of my views that is

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.