title: How to download a file to assets/www/ in android app?
body: <p>So, I'm writing an android app and I want it to display information in webView, so I've got it displaying a simple local .html file in <code>assets/www</code> and that all works, but suppose I want to change the info, perhaps add something, how could I have the app download the file from, say, Dropbox and put it into <code>assets/www</code>? Just something like:</p>
  
  <pre><code>if (isOnline()) {
              download("https://dl.dropboxusercontent.com/u/0000000/index.html", "assets/www")
  }
  else {
              Toast.makeText(this, "No internet connection, this information might be out of date", Toast.LENGTH_LONG).show();
      }
  </code></pre>
  
  <p>I have the <code>isOnline()</code> function written and working, just need the download function, but I'm not sure where to start.</p>
  
  <p>Edit, I've tried this so far:</p>
  
  <pre><code>if (isOnline()) { 
              try {
                  URL url = new URL("https://db.tt/WyAqN9r0");
                  BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                  String FILENAME = "tutortrusthandbook.html";
                  FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
                  String str;
                  while ((str = in.readLine()) != null) {
                      fos.write(str.getBytes());
                  }
                  in.close();
                  fos.close();
              } catch (MalformedURLException e) {
              } catch (IOException e) {
              } catch (Exception e) {
                  Toast.makeText(getApplicationContext(), "Exception Info " +     e.getCause(),Toast.LENGTH_LONG).show();
                  e.printStackTrace();
              }
  
          }
  WebView webview = (WebView) findViewById(R.id.webView1);
  webview.loadUrl("file://tutortrusthandbook.html");
  </code></pre>
  
  <p>But I'm not sure if it has managed anything because I don't know how to display the file now...</p>