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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:00:04+00:00 2026-06-13T05:00:04+00:00

I’m creating/saving file on SD card. This is the code: File sdDir = Environment.getExternalStorageDirectory();

  • 0

I’m creating/saving file on SD card. This is the code:

File sdDir = Environment.getExternalStorageDirectory();
public void btnsave_clicked(View v) throws FileNotFoundException, IOException{
     File f;
      f=new File(sdDir, "deposit.dma");
      if(!f.exists())
      f.createNewFile();
...
}

But when I click the button, it throws “Permission denied”.
Don’t ask me for add uses-permission.

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

I’ve already added this in Manifest.

What should I do?
LogCat info:

10-19 20:25:14.681: E/AndroidRuntime(29016): FATAL EXCEPTION: main
10-19 20:25:14.681: E/AndroidRuntime(29016): java.lang.IllegalStateException: Could not execute method of the activity
10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.view.View$1.onClick(View.java:2168)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.view.View.performClick(View.java:2552)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.view.View$PerformClick.run(View.java:9229)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.os.Handler.handleCallback(Handler.java:587)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.os.Handler.dispatchMessage(Handler.java:92)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.os.Looper.loop(Looper.java:130)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.app.ActivityThread.main(ActivityThread.java:3701)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at java.lang.reflect.Method.invokeNative(Native Method)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at java.lang.reflect.Method.invoke(Method.java:507)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at dalvik.system.NativeStart.main(Native Method)
10-19 20:25:14.681: E/AndroidRuntime(29016): Caused by: java.lang.reflect.InvocationTargetException
10-19 20:25:14.681: E/AndroidRuntime(29016):    at java.lang.reflect.Method.invokeNative(Native Method)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at java.lang.reflect.Method.invoke(Method.java:507)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.view.View$1.onClick(View.java:2163)
10-19 20:25:14.681: E/AndroidRuntime(29016):    ... 11 more
10-19 20:25:14.681: E/AndroidRuntime(29016): Caused by: java.io.IOException: Permission denied
10-19 20:25:14.681: E/AndroidRuntime(29016):    at java.io.File.createNewFileImpl(Native Method)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at java.io.File.createNewFile(File.java:1257)
10-19 20:25:14.681: E/AndroidRuntime(29016):    at org.brotheroftux.depositmaster.MainActivity.btnsave_clicked(MainActivity.java:43)
10-19 20:25:14.681: E/AndroidRuntime(29016):    ... 14 more
  • 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-13T05:00:06+00:00Added an answer on June 13, 2026 at 5:00 am

    From the Android Environment doc

    Applications should not directly use this top-level directory, in order to avoid polluting the user’s root namespace. Any files that are private to the application should be placed in a directory returned by Context.getExternalFilesDir, which the system will take care of deleting if the application is uninstalled. Other shared files should be placed in one of the directories returned by getExternalStoragePublicDirectory(String).

    In other words, this is not really a good practice (although perhaps you have some very good reason; the context isn’t very clear).

    Additionally, as Cthulhu and Ted Hopp commented, make sure the permission is in the correct location in the manifest.

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

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported

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.