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. pseudotarget of android build

Hi
It has been mentioned in the document, (build-system.html) of android
source tree that the pseudotarget - make targets will list down all
available LOCAL_MODULE. But on typing it I am getting the error
below:
  make: *** No rule to make target `targets'.  Stop.
Please let me know how can I list down all available LOCAL_MODULEs.

Thanks
Manjunatha Srinivasan
--~--~---------~--~----~------------~-------~--~----~

2. Any idea on what is "scheduleBroadcast" in Surface Flinger ?

Any idea on what is "scheduleBroadcast" in Surface Flinger ?
--~--~---------~--~----~------------~-------~--~----~

3. how to stay animation result in view?

4. How Do you enter a negative number into an EditText

5. How to get a view from a custom layout ?

6. Drawing custom images in a ListView

7. Tabs with linear layouts