Unable to get android to download misc files from webserver!

Discussion in 'Android Apps & Games' started by phodat, Nov 24, 2010.

  1. phodat

    phodat New Member
    5

    Nov 24, 2010
    4
    0
    5
    I am attempted to download some files off of a web server down to my android phone. I would prefer the download be put on the SDcard but at this point it doesn't matter. I am become quite frustrated with this.

    When I attempt to download, I get all the way to the end without exceptions thrown and I check for its existence and do not find it. In addition I cannot find the files on my SD card when looking via DDMS. When I do a directory check, I do not get any errors that the directory does not exist.

    I suspect some type of permissions issue but I can't seem to find the answer. I have verified that the web page script (PHP) is working by trying on my browser. I am able to down the file to my hearts content


    thanks in advance!!!

    private boolean WriteBytesToFile(String path,byte[] bytes)
    {
    boolean returnval =false;

    try
    {

    File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyDir" + path);

    File directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyDir" + path).getParentFile();
    if (!directory.exists() && !directory.mkdirs()) {
    logger.e("WriteBytesToFile","path does not exist ");
    }

    FileOutputStream fos = openFileOutput(path,MODE_WORLD_READABLE);
    logger.e("WriteBytesToFile","Length of file to write : " +Integer.toString(bytes.length));
    fos.write(bytes);
    fos.flush();
    fos.close();
    if (file.exists())
    {
    logger.e("WriteBytesToFile","File Exists after download");
    returnval = true;
    }
    else
    {
    logger.e("WriteBytesToFile","File Doesn't Exist after download");
    returnval = true;
    }
    }
    catch(Exception ex)
    {
    logger.e("WriteBytesToFile","Exception : " + ex.toString());
    }
    return returnval;
    }

    }
     

    Advertisement

  2. takeshi

    takeshi Well-Known Member
    163

    Dec 6, 2009
    3,354
    282
    163
    Astro has an option in it to allow the browser to download any type of file. I'm sure there are other apps and ways to achieve this as well.
     
  3. phodat

    phodat New Member
    5

    Nov 24, 2010
    4
    0
    5
    Please ignore, posted in wrong forum
     

Share This Page

Loading...