I want to create a file manager application for Android using java.nio.file API which is the part of JDK7. I think this (java.noi.file)API contains easy solutions to design file manager application where JDK6(IO) and apache commons IO API does not have the same facility.
Please give some solution, how I use the JDK7 (IO) in android application.
Thanks!
Java NIO is a buffer oriented package. It means that the data can be written/read to/from a buffer which further processed using a channel. Here, the buffers act as a container for the data as it holds the primitive data types and provides an overview of the other NIO packages.
Files is utility class holding static methods for managing file system, File is class which instances represent single path (with few additional methods allowing manipulating this path).
Originally: the simple answer was that you can't do it. Android is Java 6 based, and (AFAIK) there is no backport of Java 7's java.nio.file
classes to Android.
(That's not surprising. Porting java.nio.file
would entail significant changes to the Davlik VM's native code libraries.)
Updated: according to the Android javadocs, support for the java.nio.file
package was added to Android in API level 26. That corresponds to the Oreo release which came out in August 2017.
Can you tell me that what API should I use for my requirements. ( My requirement is File operation like : Cut|copy|delete on files and directories);
Prior to Android 26, I suggest you just use the java.io.File
class for things like making directories, renaming files, and so on, and then implement the "higher level" operations such as copying files and directory trees using File.list()
and FileInpuStream
or FileOutputStream
. You could possibly simplify some operations using classes such as the Apache commons DirectoryWalker
FileUtils
or Guava Files
.
However, I'm not sure what you are trying to achieve here. There are already existing "file manager" apps for Android.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With