Giter Club home page Giter Club logo

android-copy-assets's Introduction

android-copy-assets

bintray Download Build Status Codacy Badge Author GitHub license

Library for copying assets files and folders to the device

Download

Install android-copy-assets library.

repositories {
    jcenter()
}

dependencies {
    implementation 'com.wshunli.android:android-copy-assets:2.2.0'
}

Check out android-copy-assets releases to see more unstable versions.

How do I use android-copy-assets?

Permission

If you need write file into the EXTERNAL_STORAGE , you should add the permission:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

So if you are targeting Android 6.0+, you need to handle runtime permission request before next step.

Simple usage snippet

CopyAssets.with(this)
        .from("dir1")
        .to(externalPath)
        .copy();

For more information about Data Storage.

More

If you want copy all the files and folders in assets, you can remove the from() method.

CopyAssets.with(this)
        .to(externalPath)
        .copy();

Or the method parameters set to "".

CopyAssets.with(this)
        .from("")
        .to(externalPath)
        .copy();

You can also remove the to() method, while it means copy files and folders to Internal Storage.

CopyAssets.with(this)
        .from("")
        .copy();

CopyListener

android-copy-assets support monitoring file copy progress.

CopyAssets.with(this)
        .to(innerPath)
        .setListener(new CopyListener() {
                @Override
                public void pending(CopyCreator copyCreator, String oriPath, String desPath, List<String> names) {
                Log.d(TAG, "pending: " + names.toString());
                }

                @Override
                public void progress(CopyCreator copyCreator, File currentFile, int copyProgress) {
                Log.d(TAG, "progress: " + copyProgress + "-->currentFile:" + currentFile.getName());
                }

                @Override
                public void completed(CopyCreator copyCreator, Map<File, Boolean> results) {
                Log.d(TAG, "completed: " + results.toString());
                }

                @Override
                public void error(CopyCreator copyCreator, Throwable e) {
                Log.d(TAG, "error: " + e);
                }
        })
        .copy();

Find more details about android-copy-assets in sample.

License

Copyright 2017 wshunli

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-copy-assets's People

Contributors

wshunli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.