private file last modified date

by Dson » Sun, 01 Aug 2010 13:06:35 GMT


Sponsored Links
 Hi Guys,

 I am trying to get the last modified date of an internal file and it
always returns me 0 although I could read the file properly. Can you
please let me know if I am doing anything wrong...

Creating a file...
--------------------

FileOutputStream Os = activity.openFileOutput("file1.jpg",
Context.MODE_PRIVATE);
cachedImage.compress(CompressFormat.JPEG, 75, Os);
Os.close();


Reading the file...
--------------------
long mod_time = 0;
File file = new File("file1".jpg");
mod_time = file.lastModified();
FileInputStream Is = activity.openFileInput("file1.jpg");
cachedImage = BitmapFactory.decodeStream(Is);
Is.close();


**mod_time is always zero!!!!**

--



private file last modified date

by Mark Murphy » Sun, 01 Aug 2010 14:53:33 GMT


 


That is because you are looking at the wrong file. Use new
File(getFilesDir(), "file1.jpg") to get at the same file that you use
with openFileInput()/openFileOutput().

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

Android Training...At Your Office:  http://commonsware.com/training 

--


Sponsored Links


Other Threads

1. Still receiving sensor events after unregisterListener

I'm running on a Motorola Droid with OS 2.2.2. My app implements
SensorEventListener and uses Sensor.TYPE_ACCELEROMETER and
Sensor.TYPE_ORIENTATION. After I detect a particular event (i.e.
device shaken or flipped) I want to cancel any subsequent sensor
inputs. I have noticed a lag between calling unregisterListener and
when sensor events actually stop coming to my service. Is this normal?
Is there a way to immediately stop receiving sensor events? Or if
there is some latency between the time I unregister my sensor
listener, can I set a flag to stop processing events? I'm more
concerned with minimizing CPU cycles and battery life so I don't want
the service to run any longer than it absolutely has to.

-- George

-- 

2. Java

I heard the iPhone is coded in xcode. Why Java and not xcode? Anyone
know?

--~--~---------~--~----~------------~-------~--~----~

3. Google Map Directions

4. Opening new package to current view

5. AlerDialog inside onRecieve

6. Tutorial: Android Service Component

7. What does the icon means on status bar?