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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:05:32+00:00 2026-06-01T11:05:32+00:00

So what started as A problem with buttons, just means there is A problem

  • 0

So what started as A problem with buttons, just means there is A problem with my files. I want to save numbers to my files, and also wich languege I selected. The languege works perfect but when I try to do the same with my numbers it just go wrong

So this is the code of my languege file

french.setOnClickListener(new View.OnClickListener() {  
        public void onClick(View v) {
            try{
                buttonSound.start();
                String FILENAME = "LangFile";
                String data ="FR";
                FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
                fos.write(data.getBytes());
                fos.close();
                FILENAME="TempFile";
                data="0";
                FileOutputStream fostemp = openFileOutput(FILENAME, Context.MODE_PRIVATE);
                fostemp.write(data.getBytes());
                fostemp.close();
                startActivity(new Intent("com.technopolisapp.LOGOTECHNOPOLIS"));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            finally{
                finish();
            }               
        }
    }); 

Here I save 2 letters for the button pressed
And this is the code that reads it again and make A the buttons with the languege chosen

try{
        String FILENAME = "LangFile";
        FileInputStream fos = openFileInput(FILENAME);
        byte[] b = new byte[2];
        fos.read(b);
        fos.close();
        if(new String(b).equalsIgnoreCase("NL")){
            Tower.setText(classNamesDutch[0]);
            Puzzle.setText(classNamesDutch[1]);
            Mirror.setText(classNamesDutch[2]);
            Tangram.setText(classNamesDutch[3]);
            Frog.setText(classNamesDutch[4]);
        }
        if(new String(b).equalsIgnoreCase("GB")){
            Tower.setText(classNamesEnglish[0]);
            Puzzle.setText(classNamesEnglish[1]);
            Mirror.setText(classNamesEnglish[2]);
            Tangram.setText(classNamesEnglish[3]);
            Frog.setText(classNamesEnglish[4]);
        }
        if(new String(b).equalsIgnoreCase("FR")){
            Tower.setText(classNamesFrench[0]);
            Puzzle.setText(classNamesFrench[1]);
            Mirror.setText(classNamesFrench[2]);
            Tangram.setText(classNamesFrench[3]);
            Frog.setText(classNamesFrench[4]);
        }
    }catch (java.io.FileNotFoundException e) {
      } catch (IOException e) {
        e.printStackTrace();
    }

Now this is my code for saving and reading for my numbers

public void Savefile(){
    int level=0;
    String data;
    try{
        String FILENAME = "TowerFile";
        FileInputStream fos = openFileInput(FILENAME);
        byte[] b = new byte[1];
        fos.read(b);
        fos.close();            
        if(new String(b).equalsIgnoreCase("1")){
            level=1;
        }
        if(new String(b).equalsIgnoreCase("2")){
            level=2;
        }
        if(new String(b).equalsIgnoreCase("3")){
            level=3;
        }
        if(new String(b).equalsIgnoreCase("4")){
            level=4;
        }
        if(new String(b).equalsIgnoreCase("5")){
            level=5;
        }
        if(level!=1 || level!=2 || level!=3 || level!=4 || level!=5){
            FILENAME="TowerFile";
            data="een";
            FileOutputStream fostemp = openFileOutput(FILENAME, Context.MODE_PRIVATE);
            fostemp.write(data.getBytes());
            fostemp.close();
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

And this is the way I want to read it

try{
        String FILENAME = "TowerFile";
        FileInputStream fos = openFileInput(FILENAME);
        byte[] b = new byte[1];
        fos.read(b);
        fos.close();
        if(new String(b).equalsIgnoreCase("1")){
            button1.setVisibility(Button.GONE);
        }
        if(new String(b).equalsIgnoreCase("2")){
            level=2;
        }
        if(new String(b).equalsIgnoreCase("3")){
            level=3;
        }
        if(new String(b).equalsIgnoreCase("4")){
            level=4;
        }
        if(new String(b).equalsIgnoreCase("5")){
            level=5;
        }
    }catch (java.io.FileNotFoundException e) {
    } catch (IOException e) {
            e.printStackTrace();
    }

So I don’t really get it where it goes wrong at the moment

  • 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-01T11:05:34+00:00Added an answer on June 1, 2026 at 11:05 am

    You want to use Context.openFileStream(Context.MODE_PRIVATE). It doesn’t explain why you must do it this way, I am assuming OS permissions, but this should work for you.

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

Sidebar

Related Questions

The problem I started with is that I want to display in an ASP.NET
I am having a problem that just started happening in OS 3.1. I have
I've just started with db4o and I stumbled on to a problem. I have
I just started a graphical C++ course and I have problem getting an overview
I just started working with Android and I have a problem with my map.
I have just started learning Javascript. I want Hello World! to be written to
Just started working with android and ran into a small problem. I am have
I just started programming OOP and I'm running into a scope problem. In the
I am just started with PHP and have a rather simple problem I can't
I run into a small problem (Not surprisingly, 'cause I've just started with xcode).

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.