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. Fragmentation-resistant product design


We have noticed that while all the phones (that we have seen) store
photo timestamps in the Local timezones in which they were clicked,
the Motorola Droid Pro store EXIF photo timestamps in GMT. The photo
viewer shows it in the timezone of the viewer (Confirmed by

Any advice on how to handle this issue more from a design perspective?
As we keep identifying more issues of this sort, we are adding
abstractions at different points where our code interacts with the
system. Is this the way to go? Also, any advice on how to identify a
device? We are planning to use make and model keywords like
Make=Motorola, Model=DROID PRO, Product=venus2_vzw, Device="verizon/



2. Change UI when executing an instruction

I want to change the UI(if possible just add an image to the UI) when
i'm well connected to the server(i'm developping a SIP application) by
adding an imaged "Connected" .
In fact, i've made this but i have a FC:
public void onRegistrationDone(String localProfileUri, long
expiryTime) {
                        updateStatus("Registered to server.");
                        Log.d("SUCCEED","Registration DONE");

connected is an XMl file that has a textview(with same id as the
main.xml) and the image that i want to add.
How can i do this?

Thank you very much.


3. android sdk on FreeBSD in Linux emulation mode

4. (WTA) Cara mindahin konten sdcard

5. Which devices support point attentuation?

6. zipalign level 4 or level 8?

7. Assigned SDK-Version, minSdkVersion and ADT emulator version