How to use java.nio.file package in android?

I want to create a file manager application for Android using the java.nio.file API, which is part of JDK7. I think this (java.noi.file) API contains simple solutions for developing a file manager application, where JDK6 (IO) and apache commons IO APIs do not have the same facility.

Please give some solution on how I use JDK7 (IO) in an Android app.

Thanks!

+8
source share
1 answer

Initially : the simple answer was that you cannot do this. Android is based on Java 6, and (AFAIK) there is no java.nio.file Java 7 classes reverse port for Android.

(This is not surprising. Porting java.nio.file will entail significant changes to the Davlik VM native code libraries.)

Updated : according to Android javadocs , support for the java.nio.file package was added to Android at API level 26. This corresponds to the release of Oreo, which was released in August 2017.


Can you tell me what API I should use for my requirements. (My requirement is a file operation, for example: Cut | copy | delete for files and directories);

Prior to Android 26, I suggest you just use the java.io.File class for things like creating directories, renaming files, etc., and then implement β€œhigher level” operations, such as copying files and directory trees using File.list() and FileInpuStream or FileOutputStream . You could simplify some operations by using classes such as Apache Commons DirectoryWalker FileUtils or Guava Files .

However, I am not sure what you are seeking here. Already there are file manager applications for Android.

+15
source

Source: https://habr.com/ru/post/954498/


All Articles