0

I'm writting some code that uses a serialized file. The file is called alcala.ser and is in utils, a subfolder of java. The class calling the file is in the same folder. Here's the code:

InputStream file = new FileInputStream("/alcala.ser");

I also tried:

InputStream file = new FileInputStream("alcala.ser");

In both cases, I get

java.io.FileNotFoundException: /alcala.ser: open failed: ENOENT (No such file or directory)

How should I reference the file?

Thanks in advance.

2 Answers2

1

The file is called alcala.ser and is in utils, a subfolder of java.

Move the file out of there and into assets/. Then, use AssetManager to open() an InputStream on the asset.

CommonsWare
  • 954,112
  • 185
  • 2,315
  • 2,367
0

Check External and Internal Storage option in http://developer.android.com/guide/topics/data/data-storage.html. Depending on how do you want to handle privacy you have to chose one or the other.

Diego Torres Milano
  • 61,192
  • 8
  • 106
  • 129