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 7731997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:37:16+00:00 2026-06-01T06:37:16+00:00

In my app I want a button which when pressed copies a file stored

  • 0

In my app I want a button which when pressed copies a file stored in my apps raw folder to sdcard/Android/data… overwriting an existing file that is already there.

Here is what I have so far. The file in my raw folder is called brawler.dat for an example.

I’m not asking anyone to write the entire code, but that would be a bonus for sure.

I need mainly someone to point me in the right direction.

I can create buttons to go to URL’s etc… but I’m ready for the next level, I feel.

main.xml

 rLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Overwrite File" />

FreelineActivity.java

     package my.freeline.conquest;

import android.app.Activity;
import android.os.Bundle;

public class FreelineActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
  • 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-01T06:37:17+00:00Added an answer on June 1, 2026 at 6:37 am

    You can do the following simple call the copyRawFile().For more details on storage refer to http://developer.android.com/guide/topics/data/data-storage.html

        private void copyRawFile() {
    
    
                    InputStream in = null;
                    OutputStream out = null;
        String filename="myFile"; //sd card file name           
        try {
    //Provide the id of raw file to the openRawResource() method
                      in = getResources().openRawResource(R.raw.brawler);
                      out = new FileOutputStream("/sdcard/" + filename);
                      copyFile(in, out);
                      in.close();
                      in = null;
                      out.flush();
                      out.close();
                      out = null;
                    } catch(Exception e) {
                        Log.e("tag", e.getMessage());
                    }       
    
            }
            private void copyFile(InputStream in, OutputStream out) throws IOException {
                byte[] buffer = new byte[1024];
                int read;
                while((read = in.read(buffer)) != -1){
                  out.write(buffer, 0, read);
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to design simple app widget which has two textview and two button
I want to change my radio button text in android app with a value
I currently have an app which, when a button is pressed, and after a
When in a FB app I want to press an html button and exit
I want to implement a three way sliding button for my app. at the
Hi I made a modification in my app which is I want to close
I have an app which will start sending location data to a remote server,
I have an app which will start sending location data to a remote server,
So I have these buttons in my app that I want to open .PDF
For example, the users of our app want to search products by entering a

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.