Android copy files from assets to datafile in Internal Storage.

Copying files from assets folder to internal storage in Android is not a difficult task. It consists of three parts:

Assets folder directory structure

How to copy files from assets to Internal Storage Android - 
  1. First make sure the assets folder is in the correct location. The correct location of Assets folder in Android is youappname\app\src\main.
  2. Creating a file in the internal storage where you will write the file that is copied from the assets folder.
  3. Finally copying the file.
Here is the sample code for copying a file called yourdata.extension from the assets folder to the internal storage in a file called yourapp - 
        Context context = getApplicationContext();
        String path = Environment.getExternalStorageDirectory()+"/yourapp/";
        File file = new File(path+ "yourdata.extension");
        if (!file.exists()) {

                private void copyFile(Context context) {
        AssetManager assetManager = context.getAssets();
        try {
            InputStream in ="eng.traineddata");
            OutputStream out = new FileOutputStream(path+"yourdata.extension");
            byte[] buffer = new byte[1024];
            int read =;
            while (read != -1) {
                out.write(buffer, 0, read);
                read =;
            } catch (Exception e) {

So we've seen that copying files from assets to internal storage is pretty easy in Android, you just have to make sure that the assets folder is in the correct directory. This might be confusing at first as earlier, the location of assets folder was different, but now the location of assests folder is in the main folder of your app, i.e - yourappname\app\src\main. This sums up how to copy files from assets folder to internal storage in Android. If you have any question, feel free to drop them below. Happy coding!