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. Android V1.0 : DDMS location controls, and telnet geo fix command not working.

geo fix works but not with 0 0.
DDMS still not working.



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

2. Android V1.0 : DDMS location controls, and telnet geo fix command not working.

I tried, like in v0.9 to use the telnet geo command:
[EMAIL PROTECTED]:~$ telnet localhost 5554
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK
geo fix 0 0
OK

Then I openened the menu in the standard map application -> My
location
-> "trying to determinate your location..." then "your location cannot
be determined [...]"
I remembered in v0.9 there was an icon for the gps location provider
in the status bar: it is now missing.

Then I tested ddms controls via eclipse.
I tried manual location, then on the emulator I clicked on my location
menu item again:
"trying to determinate your location..." then "your location cannot be
determined [...]"

I tried to load the sample2.kml in the kml tab of ddms controls, I
clicked on the play button then retested on the map application: the
same thing:
"trying to determinate your location..." then "your location cannot be
determined [...]"

Plus, mock location providers have been removed, so I am totally
desesperate...
--~--~---------~--~----~------------~-------~--~----~

3. New Free HTC Dream / T-Mobile G1 Android Emulator Skins

4. My Messages won't get displayed

5. can't access XML resources from classes outside my main (launched) activity

6. T-Mobile G1 skin now available for Android Emulator!

7. .xml in layout didn't shown in R.java