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. No RTSP streaming via Wireles LAN on G1????

I have difficulties to stream a video file via RTSP using wireless LAN
inside the browser. It works fine over the cellular network (WLAN
deactivated). But if WLAN is activated the player the starts loading
the clip but eventually displays an alert window stating that video
playback is not possible.
I encountered this issue on m.youtube.com and also on another site.

Is it a bug? Maybe it is the T-Mobile branding?

--~--~---------~--~----~------------~-------~--~----~

2. Switch to SurfaceView

Im creating a simple game using a SurfaceView for drawing the
Graphics. It works fine, but now I tried to add a title screen, which
is (for now) only a LinearLayout and a Start-button, specified in XML.
However, when I click this button and try to switch to my SurfaceView
(By doing setContentView(R.layout.game), the screen turns black. But
if I do setContentView(R.layout.game) immediatly in my
Activity.onCreate it works. But not if I start with my Title-screen
and then try to switch

--~--~---------~--~----~------------~-------~--~----~

3. crash application on change mode

4. All SYMBIAN based end devices accept Java language Applications :: Need clarification

5. Eclipse Layout editor and Java 6

6. Questions related to android, please answer

7. All SYMBIAN based end devices accept Java language Applications :: Need Clarification