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",
cachedImage.compress(CompressFormat.JPEG, 75, Os);

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);

**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)  |  | 

Android Training...At Your Office: 


Sponsored Links

Other Threads

1. oot wta usb hub yang bagus buat mba

met malam manteman, maap oot sejenak

mohon saran

mba kan cuman ada 2 port usb
{*filter*}tara pengen colok ini itu (kabel data, hd external, usb flash,
wireless mouse, dll)

pake usb hub apa ya yang kuat/bagus? ada saran? maafkan pertanyaan
nubidol ini :)


2. abortBroadcast


I'm trying to use the abortBroadcast() method of the BroadcastReceiver
class, but it seems not to work.

Here's the situation:

a background service send an intent with action="X"; a
BroadcastReceiver registered in the manifest catch this intent.
When the Activity Y is in foreground it registers another BCreceiver
that responds at the same intent X.

Now, when the last receiver catch the intent i use abortBroadcast() to
prevent the first to do the same, but it doesnt work. In the activity
the abort flag is TRUE, but if i read it in the first receiver is
always FALSE.

Can anybody tell me where i do wrong?

Thanks (and sorry for my bad bad english).



4. How to change animation velocity on SlidingDrawer

5. paging om arya mada

6. App auto response

7. Broadcast in WiFi ad-hoc mode