Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.os.Bundle
- import android.support.v4.app.Fragment
- import android.view.LayoutInflater
- import android.view.View
- import android.view.ViewGroup
- import android.widget.Button
- import supe.epic.exepmple.R
- import java.io.*
- class Fragment7 : Fragment(), View.OnClickListener {
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?): View? {
- val btn: Button? = view?.findViewById(R.id.btn)
- btn?.setOnClickListener(this)
- return inflater.inflate(R.layout.frgmnt7, container, false)
- }
- fun copy() {
- val bufferSize = 1024
- val assetManager = context!!.assets
- val assetFiles = assetManager.list("")
- assetFiles.forEach {
- val inputStream = assetManager.open(it)
- val outputStream = FileOutputStream(File(context!!.filesDir, it))
- try {
- inputStream.copyTo(outputStream, bufferSize)
- } finally {
- inputStream.close()
- outputStream.flush()
- outputStream.close()
- }
- }
- }
- override fun onClick(v: View?) {
- copy()
- }
- }
Add Comment
Please, Sign In to add comment