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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:13:27+00:00 2026-06-05T14:13:27+00:00

I am attempting to write a readonly file to my SD card. I need

  • 0

I am attempting to write a readonly file to my SD card. I need to do this as a two step process.

public void method1(String cacheFilename) {
File cacheDir = mContext.getExternalCacheDir();
File cachedFileOnDisk = new File(cacheDir, cacheFilename);
FileOutputStream fileStream = new FileOutputStream(cachedFile);
fileStream.write(...)
fileStream.flush();
fileStream.close();
}
public void method2(String cacheFilename) {
   File cacheDir = mContext.getExternalCacheDir();
   File cachedFileOnDisk = new File(cacheDir, cacheFilename);
   if(!cachedFileOnDisk.setReadOnly()) {
       throw new IllegalStateException(); 
}

Where method1 is invoked and then at a subsequent stage method2.
The cachedFileOnDisk.setReadOnly() call returns a false to me and I am unable to set the file to read only.

Is there a way I could write readonly files to my SD card?

  • 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-05T14:13:29+00:00Added an answer on June 5, 2026 at 2:13 pm

    The sdcard uses a FAT-type filesystem which does not support file ownership.

    It is possible at implementation level for FAT to support a read-only bit, but that would be of limited value since anything else with sd card write permission would be free to change the bit. Given the limited value, it’s an open question if it’s even possible to set that on android.

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

Sidebar

Related Questions

I am attempting to write a program whereby I need to process a string
I am attempting to write a file to external storage in android. I keep
I am attempting to write a interpreter that will turn a string like: vector(random(0,
I'm attempting to write a text editor. I'm unable to open a file. Why?
I am attempting to write out an Excel file from an ASP.NET web server
I'm attempting to write a widget for DotNetNuke in C#. This is my first
I attempting to write a simple JQuery search. This is what I have so
I'm attempting to write a function to compare two arrays of pointers to see
I am attempting to write an application in which I have two text fields
I am curretnly attempting to write a script in python that allows me to

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.