Save files to internal memmory?

All your problems with Audio, Video and Images.

Save files to internal memmory?

Postby cruisx » Fri Apr 29, 2011 4:57 pm

Hey guys, I have a situation. Can someone tell me how to save files to the internal memory where it can be publically accesssed by any other program? I could save it to the sdcard but not everyphone has one. Im downloading a file from the web ( 500kb in size)

Code: Select all
public void Download()
     {
        try {
             //this is the file you want to download from the remote server
             String path ="http://dl.dropbox.com/u/27634579/file.bin";
             //this is the name of the local file you will create
             String targetFileName;
                 boolean eof = false;
             URL u = new URL(path);
             HttpURLConnection c = (HttpURLConnection) u.openConnection();
             c.setRequestMethod("GET");
             c.setDoOutput(true);
             c.connect();
            
             FileOutputStream f = new FileOutputStream(new File("/data/data/file.bin"));
                 InputStream in = c.getInputStream();
                 byte[] buffer = new byte[1024];
                 int len1 = 0;
                 while ( (len1 = in.read(buffer)) > 0 ) {
                 f.write(buffer,0, len1);
                          }
             f.close();
             } catch (MalformedURLException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
             } catch (ProtocolException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
             } catch (FileNotFoundException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
             } catch (IOException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }

     }
cruisx
Freshman
Freshman
 
Posts: 2
Joined: Fri Apr 29, 2011 4:52 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google [Bot] and 18 guests