Android write simple file management module

Recently, I am working on a program to import word documents into SQLite. For the problem of file selection, after repeated consideration, I decided to write a simple file management module to select the files to be imported

First look at the renderings:

Idea:

Get the storage interface, traverse the current directory, and use listview to display files and folders

First, the layout

Item layout for loading files

list_ file_ style.xml

Custom class

In order to better bind the data to the listview, I choose the custom baseadapter class

And holder for layout import

Control file

global variable

The first is to get the memory list

When we click on a folder, we open the folder and update the UI

When the program just runs, it needs to load the memory list instead of a folder, so it needs to define an additional function

Due to the problem of the memory mount point, when returning to the previous layer, it will not return to the memory list, that is, the / storage directory. In addition, some folders are empty or need to be hidden for the security of system files. It has been completed to obtain the memory list. However, if it is directly returned to the previous layer, it will enter the unsafe directory, Therefore, you need to judge whether it is to return to the root directory

With the above, you can directly call the corresponding function when creating the control file

After doing so much, it's basically completed. For the sake of user friendliness, I overloaded the return key

reference:

Method for Android to obtain internal and external memory cards

Android file manager usage details

How do I get all the memory attached to an Android device

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>