Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8335899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:48:52+00:00 2026-06-09T03:48:52+00:00

I need to upload a file from my android emulator directory (‘data\data\org.mypackage\file.dat’) to a

  • 0

I need to upload a file from my android emulator directory (‘data\data\org.mypackage\file.dat’) to a remote server, but when I try to access the file it gives an error like ‘error: Permission denied’, I store my sqlite database in ‘data\data\org.mypackage\databases\’ folder , during the application startup if there is no sqlite db in that folder I copied it from my asset folder to that directory and access it from there it works perfect but in the case upload task it ask for permission why this occur? following is my uploadFile method

    private void uploadFile(){ 

    HttpURLConnection conn = null; 
    DataOutputStream dos = null; 
    DataInputStream inStream = null; 
    String existingFileName="/data/data/org.mypackage/file.dat";
    GeneralFunctions.comment(existingFileName);
    String lineEnd = "\r\n"; 
    String twoHyphens = "--"; 
    String boundary =  "*****"; 
    int bytesRead, bytesAvailable, bufferSize; 
    byte[] buffer; 
    int maxBufferSize = 1*1024*1024; 
    String responseFromServer = ""; 
    String urlString = "http://117.231.150.213:8080/upload.jsp"; 
    try 
    { 
     //------------------ CLIENT REQUEST 
    FileInputStream fileInputStream = new FileInputStream(new File(existingFileName) ); 
     // open a URL connection to the Servlet 
     URL url = new URL(urlString); 
     // Open a HTTP connection to the URL 
     conn = (HttpURLConnection) url.openConnection(); 
     // Allow Inputs 
     conn.setDoInput(true); 
     // Allow Outputs 
     conn.setDoOutput(true); 
     // Don't use a cached copy. 
     conn.setUseCaches(false); 
     // Use a post method. 
     conn.setRequestMethod("POST"); 
     conn.setRequestProperty("Connection", "Keep-Alive"); 
     conn.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary); 
     dos = new DataOutputStream( conn.getOutputStream() ); 
     dos.writeBytes(twoHyphens + boundary + lineEnd); 
     dos.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + existingFileName + "\"" + lineEnd); 
     dos.writeBytes(lineEnd); 
     // create a buffer of maximum size 
     bytesAvailable = fileInputStream.available(); 
     bufferSize = Math.min(bytesAvailable, maxBufferSize); 
     buffer = new byte[bufferSize]; 
     // read file and write it into form... 
     bytesRead = fileInputStream.read(buffer, 0, bufferSize); 
     while (bytesRead > 0) 
     { 
      dos.write(buffer, 0, bufferSize); 
      bytesAvailable = fileInputStream.available(); 
      bufferSize = Math.min(bytesAvailable, maxBufferSize); 
      bytesRead = fileInputStream.read(buffer, 0, bufferSize); 
     } 
     // send multipart form data necesssary after file data... 
     dos.writeBytes(lineEnd); 
     dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd); 
     // close streams 
     GF.showToast("File is written"); 
     fileInputStream.close(); 
     dos.flush(); 
     dos.close(); 
    } 
    catch (Exception ex) 
    { 
         GeneralFunctions.exception("error: " + ex.getMessage()); 
    } 

    //------------------ read the SERVER RESPONSE 
    try { 
          inStream = new DataInputStream ( conn.getInputStream() ); 
          String str; 

          while (( str = inStream.readLine()) != null) 
          { 
              GeneralFunctions.comment("Server Response "+str); 
          } 
          inStream.close(); 

    } 
    catch (Exception ioex){ 
          GeneralFunctions.exception("error: " + ioex.getMessage()); 
    } 
  } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:48:53+00:00Added an answer on June 9, 2026 at 3:48 am

    Add INTERNET permission to your manifest.

    If you can provide logcat then it will help more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to upload .dat file from jsp page. I am using struts. I
I need to upload a xml file from server side, where the contents of
I need to upload a file from the client to an asp.net page. The
I need a little help here: I get a file from an HTML upload
I need to continuously upload a generated file from Azure to client's FTP but
currently i am working on the nd file upload and download from ftp server
I need to upload file the server via .php file, and i've got this
I need to upload some DATA inside and FTP server. Following stackoverflow posts on
after processing a upload file received from an external website, we need to send
hi friends iam trying to upload a file from the android device to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.