In my Android app, I am trying to create the following folder on an SD card:
/mnt/sdcard/OSGiComponents/admin/felix-cache/
Here is the code:
File cacheDir = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + "/OSGiComponents/admin/felix-cache/" ); // Create the folder cacheDir.mkdirs(); // Check if it exists if ( ! cacheDir.exists() ) { Log.e ( "Debug" , "Cache directory cannot be created" ); }
I have WRITE_STORAGE_PERMISSION in the manifest tag of an android manifest file. I can create other folders and files without problems on the SD card. The application works fine on the following phones:
- Nexus S (root) runs Gingerbread (2.3)
- Nexus S (unrooted) runs Jelly Bean (4.1.2)
- HTC Desire (with root) runs Froyo (2.2)
- HTC Desire (untouched) runs Froyo (2.2)
However, Ice Cream Sandwich (4.0.4) runs on the Samsung Galaxy Nexus (without root), the directory is created as a zero-size file that can be seen in Astro. Calling exists () returns false.

- As you can see from the folder name, I am using Apache Felix. Felix automatically creates a cache directory if it does not exist. At Galaxy Nexus, he always complained that he could not create a cache directory. Astro displays a 0-byte file instead of a folder. This is why I decided to try creating a cache folder before initializing Felix.
- So, I create the cache folder myself. The application works fine for the first time, and I see a folder in Astro. If I close the application and then delete the folder in Astro and then run the application again, even my code will not mysteriously be able to create the cache directory, and Astro will display a 0-byte file.
- A 0-byte file cannot be deleted in Astro. However, when I restart the phone, the folder there is magical and normal.
- I use FileInstall to view the OSGiComponents / install folder. When I drop packets to this folder, it is detected and installed normally on all phones except Galaxy Nexus (when the application works for the first time). There are no logs / errors in FileInstall about the impossibility of viewing the directory.
- I tested this on 2 Galaxy Nexus phones, same problem.
I suspect this is a permissions issue, but I'm not sure what it is and why a 0 byte file is being created and exists () returns false. Nowhere in the code do I create this file.
Any suggestions on what could be the problem?
Thanks:)
UPDATE: I think I have identified the problem, see the answer I posted.
Kartik sankaran
source share