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. Upgrade HTC HERO

Dear all...

Saya baru pake android neh, lam kenal...
Untuk HERO, bisa upgrade ke eclair ga sih? Caranya gimana ya??
Thanks before

Sent from my New HTC

-- 
"Indonesian Android Community [id-android]" 

2. Soft Home, Menu, Back keys in status bar

I have a device with no hard buttons, on which I need to get Android
running. The basic port is done, but I need to provide access to Home,
Menu, and Back. The Archos tablets put soft buttons in the status bar,
and I'm told that the android-x86 folks have implemented this as well
(though I haven't found it in their source yet). Can anybody offer any
suggestions on how to go about this?

Thanks,
   Aaron

-- 

3. Nanya GPS

4. Ask HF

5. Attn: Devs running games or apps in compatibility modes

6. Speedtest Matrix @Slipi

7. Drawing failure?