Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileOutputStream doesn't create Writable file

Status
Not open for further replies.

Rajesh Karunakaran

Programmer
Sep 29, 2016
549
MU
Hi Friends,

First of all, thank you all of you in advance!
I am not an expert in Android and this is my first query in this forum.

I am trying to write a bitmap to any of the usual internal folders like 'Pictures, Documents, Download' etc. Below is the file creation I am doing

Java:
String root = Environment.getRootDirectory().toString();
File myDir = new File(root + File.separator + Environment.DIRECTORY_PICTURES);
String Filename = "pic.png";
File fl = new File(myDir + File.separator + Filename);
FileOutputStream out = new FileOutputStream(fl);

At the last line, it throws as exception and says 'No such File/Directory'.
When I checked, fl.canWrite(), is says false!, i.e. fl is not writable.

I even tried to give 'Unrestricted Access' in my testing mobile for this App.

What could be the problem? What kind of additional things I need to do?
Can anyone help please ?

Rajesh

 
Dear marcosuve,

I really don't understand why you're in this forum and what are you doing here!

By the way, as mikehook said, the information you shared is priceless! Fantastic!

With lots of lov'
Rajesh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top