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. Launch Browser in maximised/minimised mode

Hi All,
I am launching browser by code:

                Intent myIntent = new Intent(Intent.ACTION_VIEW,

as its working fine.

Now the issue is OEM behavior while launching it. My app is a network
app that registers with a server for some registration data and
depending on response acts accordingly eg if i get a URL in response
launch it otherwise launch default URL.

Launch my app on android simulator/device. Network communication
starts. While network process is in progress. Press 'Home' button on
device. Wait for some time.(say 10 seconds)

"Behaviour in Android emulator/device ver 1.6:"
Nothing will happen. But when now i click browser icon explicitly the
site I requested(URL from my server) will be displayed.

"Behaviour in Android emulator/device ver 2.2:"
Suddenly browser will launch and will start getting the content for
the URL (that I got from my server and launched browser).

So the difference is how the OEM is launching the activity. A1.6
launched it in background but A2.2 will launch it in foreground.

Can anyone help me can I pass on some parameters in startActivity so
that the behavior is uniform and I can control it rather than OEM

sam g


2. deploying AccountAuthenticator for multiple apps

How should I go about deploying the same AccountAuthenticator
for multiple projects that use the same kind of account?
Should each project include the AccountAuthenticator as a library-jar
or should it be it's own apk?
What happens if the same AccountAuthenticator is exported
from multiple apks in the system? Are they listed once or
multiple times (thus confusing the user)?



3. Debug Native Code in eclipse

4. How do I capture and loop video to the screen?

5. how to implement handler pause on another activity running this activity finish next continue handler

6. Store Bitmap in Device, hence creating a file

7. Unable to run monkey for 40 Packages