package com.exercise.AndroidFile;
import java.io.File;
import java.util.Date;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class AndroidFileActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView info = (TextView)findViewById(R.id.info);
File file = new File("/sdcard/test.txt");
String AbsolutePath = file.getAbsolutePath();
String Path = file.getPath();
String Parent = file.getParent();
String Name = file.getName();
long lastModified = file.lastModified();
Date lastModifiedDate = new Date(lastModified);
info.setText(
"AbsolutePath: " + AbsolutePath + "\n" +
"Path: " + Path + "\n" +
"Parent: " + Parent + "\n" +
"Name: " + Name + "\n" +
"lastModified: " + lastModified + "\n" +
"lastModifiedDate: " + lastModifiedDate
);
}
}
Monday, 22 August 2011
Get file info
Example of getting file info, such as path, last modified Date Time.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment