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. Where's my database's file???

For example :
When i want to create a database, i offen use command like:
private static final String DATABASE_CREATE =
            "create table NOTES (_id integer primary key
autoincrement, "
                    + "title text not null, body text not null);";
db.execSQL(DATABASE_CREATE);


NOW, I want to know the location of  database file( NOTES ) that I've
created in my computer but not found.
Do you know???

Thanksssssss




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

2. EditText - how to respond to soft keyboard enter?

I have a very simple screen consisting of an EditText for entering a
number, a bunch of TextViews that display results based on the number,
and a RadioGroup to select a mode.

What I want is the screen to do is recompute the results when the user
finishes entering a new number either by pressing the enter key on a
real keyboard or the done key on the virtual keyboard.  I assume this
is pretty standard, but if this is not the best practice I would love
to know.  I have an onKeyListener set on the EditText to capture the
enter key.  It works fine with the real keyboard, but it never gets
called by the soft keyboard.

I also have a problem keeping the focus on the edittext after the
enter key is pressed.  It jumps to a radio button, which is not
desired.  I tried executing v.requestFocus() in the listener right
before the "return true", but it is ignored.

Thanks in advance for any help.

Bruce
--~--~---------~--~----~------------~-------~--~----~

3. Touch event: Delayed reception from actual touch?

4. onSearchRequested() doesn't call search activity in 1.5

5. Change button color on Focus and on click

6. sonar/ecolocation app

7. send SMS, RESULT_ERROR_GENERIC_FAILURE