title: Permission Denied in Android How to solve it?
body: <p>I trying this code but i always show the error Permission Denied.and i try code in below.</p>
  
  <pre><code> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.hope.project"
      android:versionCode="1"
      android:versionName="1.0"&gt;
       &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" /&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
        &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
        &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
        &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
      &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /&gt;
      &lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt;
      &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;
      &lt;uses-permission android:name="android.permission.RECORD_VIDEO"/&gt;
      &lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /&gt;
      &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_CONTACTS" /&gt;   
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;   
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.BROADCAST_STICKY" /&gt;
      &lt;uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/&gt;
  
      &lt;application android:label="@string/app_name"
          android:icon="@drawable/ic_launcher"
          android:theme="@style/AppTheme"&gt;
  
           &lt;activity android:name="com.hope.project.MainActivity" android:label="@string/app_name"
                  android:theme="@android:style/Theme.Black.NoTitleBar"
                  android:configChanges="keyboardHidden|orientation"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>and i display in error:</p>
  
  <pre><code> 01-25 17:24:17.853: DEBUG/szipinf(12612): Initializing inflate state
  01-25 17:24:17.853: DEBUG/szipinf(12612): Initializing zlib to inflate
  01-25 17:24:19.201: DEBUG/dalvikvm(338): GC_EXPLICIT freed 17K, 5% free 6276K/6599K, paused 3ms+115ms
  01-25 17:24:25.424: DEBUG/dalvikvm(206): GC_EXPLICIT freed 153K, 6% free 6730K/7111K, paused 4ms+94ms
  01-25 17:25:11.912: DEBUG/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
  01-25 17:25:24.961: VERBOSE/log(12612): onPageFinished: file:///android_asset/www/index.html#goToNode/2
  01-25 17:25:27.276: VERBOSE/log(12612):  on ovverRide about:blank
  01-25 17:25:44.464: VERBOSE/log(12612): onPageFinished: file:///android_asset/www/index.html#goToNode/328
  01-25 17:26:25.692: VERBOSE/log(12612): onPageFinished: file:///android_asset/www/index.html#goToNode/10
  01-25 17:26:25.901: DEBUG/dalvikvm(12612): GC_CONCURRENT freed 619K, 10% free 7242K/8007K, paused 4ms+3ms
  01-25 17:26:33.711: VERBOSE/log(12612): login main url http://imprintingdesign.com/hiren_testing/TestHopeNew/testHope/pdf/TheMountain.mp4
  01-25 17:26:33.781: VERBOSE/log(12612): login main url[0] http://imprintingdesign.com/hiren_testing/TestHopeNew/testHope/pdf/TheMountain.mp4
  01-25 17:26:35.631: ERROR/Error:(12612): /mnt/sdcard/Downloads/TheMountain.mp4 (Permission denied)
  </code></pre>
  
  <p>and my downloaded class in below:</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      WebView myWebView;
      TextView mDisplay;
      AsyncTask&lt;Void, Void, Void&gt; mRegisterTask;
  
      String Message;
      String deviceId;
      String regId;
      IntentFilter gcmFilter;
      SharedPreferences sharedPref;
      private final String PATH = "/sdcard/download/";
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          myWebView = (WebView)findViewById(R.id.webView1);
  
  
          final JavaScriptInterface myJavaScriptInterface = new JavaScriptInterface(
                  this);
          myWebView.addJavascriptInterface(myJavaScriptInterface,
                  "AndroidFunction");
  
          WebSettings settings = myWebView.getSettings();
          settings.setJavaScriptEnabled(true);
          settings.setDatabaseEnabled(true);
          settings.setDomStorageEnabled(true);
          settings.setAllowFileAccess(true);
          settings.setBuiltInZoomControls(true);
          settings.setUseWideViewPort(true);
          settings.setJavaScriptCanOpenWindowsAutomatically(true);
          settings.setLoadWithOverviewMode(true);
          myWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
  
  
           myWebView.setWebViewClient(new WebViewClient() {  
                 public boolean shouldOverrideUrlLoading(WebView view, String url)  {                  
  
                              //handle stuff here 
                              //e.g. view.loadUrl(url);   
                     Log.v("log"," on ovverRide " + url);
                              return true;    
                          }
  
                          public void onPageFinished(WebView view, String url) {
                              //dismiss the indeterminate progress dialog
                              Log.v("log", "onPageFinished: " + url);
                              myWebView.setEnabled(false);
  
                          } 
                      });
  
          myWebView.loadUrl("file:///android_asset/www/index.html");
  
  
      }
  
      @Override
      protected void onDestroy() {
          super.onDestroy();
      }
      public class JavaScriptInterface {
          Context mContext;
  
          JavaScriptInterface(Context c) {
              mContext = c;
          }
          public void DownloadUrl(String url) {
              Log.v("log","login main url " + url);
  
              String file_url = url;
              new DownloadFileFromURL().execute(file_url);
              //new DownloadFromUrl(v,g);
  
              /*String url_new = "http://"+url;
              Intent i = new Intent(Intent.ACTION_VIEW);
              i.setData(Uri.parse(url_new));
              startActivity(i);*/
  
          }
      }
  
  
      class DownloadFileFromURL extends AsyncTask&lt;String, String, String&gt; {
  
          /**
           * Before starting background thread
           * Show Progress Bar Dialog
           * */
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              //showDialog(progress_bar_type);
          }
  
          /**
           * Downloading file in background thread
           * */
          @Override
          protected String doInBackground(String... f_url) {
              int count;
               Log.v("log","login main url[0] " + f_url[0]);
              try {
                  URL url = new URL(f_url[0]);
                  String name = f_url[0].substring(f_url[0].lastIndexOf("/") + 1);
                  URLConnection conection = url.openConnection();
                  conection.connect();
                  // getting file length
                  int lenghtOfFile = conection.getContentLength();
  
                  // input stream to read file - with 8k buffer
                  InputStream input = new BufferedInputStream(url.openStream(), 1024 * 5);
  
                  // Output stream to write file
                  //OutputStream output = new FileOutputStream("/sdcard/downloadedfile.jpg");
                  OutputStream output = new FileOutputStream(Environment.getExternalStorageDirectory() + "/Downloads/"
                  + name);
                  byte data[] = new byte[5 * 1024];
  
                  long total = 0;
  
                  while ((count = input.read(data)) != -1) {
                      total += count;
                      // publishing the progress....
                      // After this onProgressUpdate will be called
                      publishProgress(""+(int)((total*100)/lenghtOfFile));
  
                      // writing data to file
                      output.write(data, 0, count);
                  }
  
                  // flushing output
                  output.flush();
  
                  // closing streams
                  output.close();
                  input.close();
  
              } catch (Exception e) {
                  Log.e("Error: ", e.getMessage());
              }
  
              return null;
          }
  
          /**
           * Updating progress bar
           * */
          protected void onProgressUpdate(String... progress) 
          {
              // setting progress percentage
              //pDialog.setProgress(Integer.parseInt(progress[0]));
         }
  
          /**
           * After completing background task
           * Dismiss the progress dialog
           * **/
          @Override
          protected void onPostExecute(String file_url) {
              // dismiss the dialog after the file was downloaded
              //dismissDialog(progress_bar_type);
  
              // Displaying downloaded image into image view
              // Reading image path from sdcard
              //String imagePath = Environment.getExternalStorageDirectory().toString() + "/downloadedfile.jpg";
              // setting downloaded into image view
              //my_image.setImageDrawable(Drawable.createFromPath(imagePath));
          }
  
      }
  </code></pre>