code to donload a file and copy it in SDCard,and get file created Android

 ///if SDCard is Existed then,download files categories.xml , Audios.xml , Reviews.xml , Video.xml files in SDCard as follows.
        try {
            URL url = new URL("");               
            InputStream input = url.openStream();               
        try {
            //place image in SdCard..
            //below two lines are same,but the difference is their API levels..
            //System.out.println("Local Path for sdcard==== "+getExternalFilesDir(null));//API Level-8
            System.out.println("Local Path for sdcard==== "+Environment.getExternalStorageDirectory()+"/Category.xml");//API Level-1                  
            OutputStream output = new FileOutputStream(Environment.getExternalStorageDirectory()+"/Category.xml");
            try {
                int aReasonableSize = 1000;
                byte[] buffer = new byte[aReasonableSize];
                int bytesRead = 0;
                while ((bytesRead =, 0, buffer.length)) >= 0) {
                    output.write(buffer, 0, bytesRead);//buffer.length);
            } //try
            finally {
        } finally {
        }catch (Exception e) {
        ///code to get file last modified dateee
        File fXmlFile = new File("sdcard/Category.xml");
        Date localFileDate = new Date(fXmlFile.lastModified());


Popular posts from this blog

Custom Dialog with no title and full screen in Android

code to display .pdf,.text,.DOC,.DOCX,.doc extension files exists in SDCard

Best working code to set Date limits on Date Picker Dialog,in Android