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

Guys

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
https://supportforums.motorola.com/thread/39204).

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/
venus2_vzw/cdma_venus2/venus2:2.2.1/3.4.2_80_V2_87/8:user/release-
keys"

Vikram

-- 

2. Change UI when executing an instruction

Hello,
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");
                        setContentView(R.layout.connected);
                        }

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