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. LG-debug

Hello all,
I am trying to Deploy my code from Eclipse to LG Ally mobile, I need to test
it on LG Ally. My laptop wouldn't recognize the device, I need to test my
code, what do I do now.
I did not find the drivers online. I have droid , and it is working fine, is
there a way I can transfer the .apk installed in droid to lg Ally. It will
be great. The thing is code should work in both mobile. It is working in
Droid not in Ally. I had sent my code to friends laptop and she downloaded
code to Ally. so please help. Thanks.

-- 

2. button layout

Hi,

I created a button and set the background image on it.  How can I set the
text below the graphic to sit on the bottom but not on top of the graphic?

hatted

-- 

3. the emulator doesnt show up

4. Which Android Version to Develop for?

5. Droid font and Romanian language support (ISO-8859-16)

6. How to unzip multiple files zipped in a zip file with individual name automatically?

7. Full size image with scroll ability