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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:25:38+00:00 2026-05-26T15:25:38+00:00

I have bought a book (Beginning Android Games) by Mario Zechner. On page 149,

  • 0

I have bought a book (“Beginning Android Games”) by Mario Zechner. On page 149, he talks about saving and opening a file on External Storage. I understand the code, however I dont understand WHY it says this:

Screenshot of error

Why does it say this? I have all the permissions in my Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amzoft.android.reference"
android:versionCode="1"
android:versionName="1.0" 
android:installLocation="preferExternal">

<application
    android:label="Android Reference"
    android:icon="@drawable/ic_launcher"
    android:debuggable="true">
    <activity
        android:label="Android Reference"
        android:name=".AndroidReferenceActivity" 
        android:screenOrientation="portrait"
        android:configChanges="keyboard|keyboardHidden|orientation">
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity 
        android:label="LifeCycleTest"
        android:name=".LifeCycleTest"
        android:configChanges="keyboard|keyboardHidden|orientation"/>
    <activity 
        android:label="SingleTouchTest"
        android:name=".SingleTouchTest"
        android:configChanges="keyboard|keyboardHidden|orientation"/>
    <activity 
        android:label="MultiTouchTest"
        android:name=".MultiTouchTest"
        android:configChanges="keyboard|keyboardHidden|orientation"/>
    <activity 
        android:label="KeyTest"
        android:name=".KeyTest"
        android:configChanges="keyboard|keyboardHidden|orientation"/>
     <activity 
        android:label="AccelerometerTest"
        android:name=".AccelerometerTest"
        android:configChanges="keyboard|keyboardHidden|orientation"/>
     <activity 
        android:label="AssetsTest"
        android:name=".AssetsTest"
        android:configChanges="keyboard|keyboardHidden|orientation"/>
     <activity 
        android:label="ExternalStorageTest"
        android:name=".ExternalStorageTest"
        android:configChanges="keyboard|keyboardHidden|orientation"/>
</application>
<uses-sdk android:minSdkVersion="8"  android:targetSdkVersion="10"/>
<uses-permission android:name="android.permisson.WRITE_EXTERNAL_STORAGE" android:required="true"/>
<uses-permission android:name="android.permission.WAKE_LOCK" android:required="false"/>

And my code:

package com.amzoft.android.reference;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.widget.TextView;

public class ExternalStorageTest extends Activity{

@Override
public void onCreate(Bundle saveInstanceState)
{
    super.onCreate(saveInstanceState);
    TextView textView = new TextView(this);
    setContentView(textView);

    String state = Environment.getExternalStorageState();
    if(!state.equals(Environment.MEDIA_MOUNTED))
    {
        textView.setText("SD card is not mounted");
    }else{
        File externalDir = Environment.getExternalStorageDirectory();
        File textFile = new File(externalDir.getAbsolutePath() + File.separator + "text.txt");

        try{
            writeTextFile(textFile, "This is a test >:0\nLINE BREAK");
            String text = readTextFile(textFile);
            textView.setText(text);
            if(!textFile.delete())
            {
                textView.setText("Couldn't remove temporary directory,     sorry mate.");
            }
        }catch(Exception e){
            textView.setText(e.getMessage());
        }
    }   
}

private void writeTextFile(File file, String text) throws IOException
{
    BufferedWriter writer = new BufferedWriter(new FileWriter(file));
    writer.write(text);
    writer.close();
}

private String readTextFile(File file) throws IOException
{
    BufferedReader reader = new BufferedReader(new FileReader(file));
    StringBuilder text = new StringBuilder();
    String line;
    while((line = reader.readLine()) != null)
    {
        text.append(line);
        text.append("\n");//BECAUSE ITS A LINE :D
    }
    reader.close();
    return text.toString();
}

}

I hope someone can help me, because Im confused right now.

  • 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-26T15:25:39+00:00Added an answer on May 26, 2026 at 3:25 pm

    i think its permissions issue add both of these to Manifest file

    <uses-permission android:name="android.permisson.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    

    let me know how it turns out

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

Sidebar

Related Questions

I'm currently learning algorithms from a book I have bought from Amazon but it
As a beginning programmer, I recently bought the book 'Algorithms - Forth Edition' by
I mainly do .Net development but have just bought an Apple Mac Book Pro
helo everyone This is a code from a book i have bought. It gives
I have tried to work this out myself (even bought a Kindle book!), but
We are developing a dictionary application for Android. We have bought authorized dictionary contents
I have recently bought a book called The c# programming language 4th edition. On
I bought a book about MVC 3. In this book, there is an example
i have bought a template that have built in contact form problem is that
I have just bought a VPS running Ubuntu and I need to install the

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.