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

  • Home
  • SEARCH
  • 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 8921605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:35:15+00:00 2026-06-15T06:35:15+00:00

I am writing an Android application and I need to copy 2 files into

  • 0

I am writing an Android application and I need to copy 2 files into the device’ s internal storage. Currently I am able to run my application after manually copying these two files under the device’ s “/data/data/[my_package_name]/files” folder using DDMS. I need to put these two files into that folder(or any folder) while my application is being installed on the device. The tip here says files within the “res/raw/” directory will be deployed to the device and will be accessible through openRawResource(), but it doesn’ t tell where these files will be put inside the internal memory. To summerize, I have two files in my project folder(assets, raw, any other folder) and I need to copy these two inside a path of internal memory. How can I achieve this? Do I need any permissions included to my AndroidManifest.xml?

Thank you in advance

  • 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-15T06:35:16+00:00Added an answer on June 15, 2026 at 6:35 am

    No big deal. There are several ways of doing this, probably shorter than this one, though.

    InputStream is = AssetManager.open("somefile.txt");
    File outputFile = new File(getExternalFilesDir(), "somefile.txt");
    OutputStream os = new FileOutputStream(outputFile);
    
    //Now copy is to os. I'd recommend using Apache Commons IO
    org.apache.commons.io.IOUtils.copy(is, os));
    

    And yes, you need permissions to write to SDcard (WRITE_EXTERNAL_STORAGE).

    UPDATE:
    Just to clarify: What the tip says is:

    Tip: If you want to save a static file in your application at compile time, save the file in your project res/raw/ directory. You can open it with openRawResource(), passing the R.raw. resource ID. This method returns an InputStream that you can use to read the file (but you cannot write to the original file).

    The files in assets folder are included in the apk, but these are read only and they are never deployed to the internal or external memory. If you need to do that you’ll have to do it by yourself, as shown in the example above.

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

Sidebar

Related Questions

I am currently writing a Android application. I need to connect to a internet
I am writing an native application in C++ under android, and I need to
I'm writing an Android application that I want to be able to send requests
I am writing an Android application where I need to populate GalleryView with images
i'm writing an Android app and i've run into a bit of a roadblock
I'm writing an android application, and i need to recognize if the text i
I am writing an Android application where I need to display Image Captured through
I am writing an android application and I need to have two classes use
Problem Description I am writing Android application and I need to add to my
I'm currently writing an Android application which needs to use OCR within it. To

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.