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",
cachedImage.compress(CompressFormat.JPEG, 75, Os);

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);

**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)  |  | 

Android Training...At Your Office: 


Sponsored Links

Other Threads

1. work with widget and screen oriantation

i m working on a widget
and i have trubles changing the widget layout whenscreen oriantation

so my quastion is
How to change the widget layout when the screen oriantation is
changed ?


2. Using TabHost with Dynamically built (pre-existing Views)

I have a remove assistant app, which allows customers to perform a
subset of functions of a desktop application, untethered.  Results are
communicated back & forth via messages left at a license server.  In
order to have a single source for the logic of the assistant, yet run
on multiple platforms (Swing, MIDP, & Android), I write a driver
composed of Database, Network, & Display pieces.

The Android driver is nearly complete, but I run into a brick wall
when it comes to Tabs.  All views are instanced calling code, not XML
defined.  I already have the view before I try to add it.  I tried sub-
classing TabHost:
    class DynamicTabHost extends android.widget.TabHost{
        public DynamicTabHost(android.content.Context context){
            super.setup(); // errors with: Your TabHost must have a
TabWidget whose id attribute is ''
        public void addTab(View view, String tabTitle){
            android.widget.TabHost.TabSpec tabSpec = super.newTabSpec
            tabSpec.setContent(new PreExistingViewFactory(view));


    class PreExistingViewFactory implements
        private final View preExisting;

        public PreExistingViewFactory(View view){ preExisting =
view; }
        public View createTabContent(String tag) { return
preExisting; }
As is shown in the code, it errors in setup.  Looking further down in
setup() I will also get this exception too:
Your TabHost must have a FrameLayout whose id attribute is

Is there a way to trick setup() into instancing me mTabWidget &
mTabContent members?


3. Commit

4. Data Typists Needed ! Work from home, Great Income!

5. stupid camera.startPreview question

6. If I buy a Dev G1 phone, will it be delivered to my US address as registered item or not?

7. implementation of onDestroy for a service containing a worker or backround thread