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. Does anyone has the documentation of window manager?

I have the entire source code base, but I would like to have some documents
which illustrates the working of this window manager.

Karthik







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

2. socket response handling problem

hi,

       I want to develop a socket program.in this login page i opened
one socket connection in one outgoingcommand  thread class  and send
command to the server.I got response from server to incommingCommand
thread class.According to response i want display  errorDialog or next
Activity.

                       Intent  intent = new Intent
(context,NextScreen.class);
                        startActivity(intent);

I can write these statements because incommingCommand class is not
extending from Activity.
Is there any solution to display  next Activity,.

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

3. TV API for Android...

4. "animation-less" android menus

5. What to do when users are advertising pirated apps in my app's comments

6. A question about displayzoomcontrols(boolean takeFocus)

7. .apk file deleted