File Not Found Saving Object to Phone File Directory


I am trying to write a object to file and retrieve it later from a different activity. When opening the Input stream to retrieve the object I get the IO exception:


java.io.FileNotFoundException: /data/data/com.mooney.diveapp/files/savedDiveLocations: open failed: ENOENT (No such file or directory)


The String and File initialisation:

String fileName="savedDiveLocations"; File theFileName; theFileName= new File(objectConetxActivity.getFilesDir(), fileName);

The code here returns a object from the file where it is saved previously:

String fileAddress = objectConetxActivity.getFilesDir()+ fileName; ObjectInputStream ois = null; FileInputStream streamIn=null; Object locationObject = null; try{ // except thrown here streamIn = new FileInputStream(fileAddress); // address of file ois = new ObjectInputStream(streamIn); locationObject = ois.readObject(); }catch (Exception e){

And writing a object to file:

ObjectOutputStream oos = null; FileOutputStream fout = null; // save to internal durectpry as opposed to exteranl SD card try{ String fileAddress = objectConetxActivity.getFilesDir()+ fileName; fout = new FileOutputStream(fileAddress); // filepath oos = new ObjectOutputStream(fout); oos.writeObject(mapLocationsObject); }catch(Exception ex){...

Any input appreciated.


Just executing theFileName= new File(objectConetxActivity.getFilesDir(), fileName); alone will not create your file.

You have to call theFileName.createNewFile();. And make sure that method returns true. That means the file was effectively created.


  • VB.NET XML Serialization Repeat third child Element
  • OdbcConnection.GetSchema(“TABLES”); not working
  • Rpmbuild copying folders specified by a mapping file
  • OpenSSL S/MIME signature with .NET
  • Rails - Passing Arrays as Params in Model Function
  • How can I get the same/to pass parameters between decorator and decorated function?
  • How to decode base64 file into binary in Python?
  • PHP - Running exec multiple php files
  • Get full path to a video file from uri
  • Prebuilt Spark 2.1.0 creates metastore_db folder and derby.log when launching spark-shell
  • set a new context to WebView
  • How to convert all *.potx files to *.pptx files with VBA?
  • Numpy : Grouping/ binning values based on associations
  • Unsetting WooCommerce shipping method based on cart items shipping classes
  • Error while accessing shared preferences of Android App's first run
  • Yomu and Heroku
  • Aptana 3 Github Clone Repository Fail
  • qnx get resmgr_context_t of old resource manager
  • could not install electron in windows 10
  • Broccoli-compass and ember-cli 0.39
  • JITSU FAILED TO INSTALL OSX [node 0.8.17 and NPM 1.2.0] WTF
  • Unable to install Git-core+svn by MacPorts
  • VSO Build — Response status code does not indicate success: 404 (Not Found)
  • Checking free space on FTP server
  • How to install a .deb file on a jailbroken iphone programmatically?
  • Change Inet root folder for iis 7
  • Handling un-mapped Rest path
  • ilmerge with a PFX file
  • Can I make an Android app that runs a web view in Chrome 39?
  • Updated Ionic CLI but shows previous version (Windows)
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • coudnt use logback because of log4j
  • LevelDB C iterator
  • Linking SubReports Without LinkChild/LinkMaster
  • apache spark aggregate function using min value
  • Sorting a 2D array using the second column C++
  • reshape alternating columns in less time and using less memory