SlideShare a Scribd company logo
Develop on Android
Android Lab Test
www.AndroidLabTest.com
Youku
By Bruno Delb
www.weibo.com/brunodelb
i.youku.com/brunodelb | www.weibo.com/brunodelb | blog.delb.cn
http://i.youku.com/brunoparis
Weibo
Officialsite
Lesson : The list of root directories
The list of the root directories
• In this lesson, you will learn to use the file manager to list
the list of root files.
• For this, you will use File and listFiles.
The list of the root directories
• In order to know the path to the application directory, use the
method getFilesDir().
File file = this.getFilesDir();
• In order to know the absolute path to a directory, use the method
getAbsolutePath() :
String text = "Local storage : " + file.getAbsolutePath();
The list of the root directories
• To get the list of directories and files at the root, use the
method listRoots().
File[] files = File.listRoots();
The list of the root directories
• To know if an entry of a directory is a directory, use the method
isDirectory() :
if (file.isDirectory()) {
}
• To get he list of the files and directories of a directory, use the
method listFiles() :
rootFile.listFiles()
Layout main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:id="@+id/et_output"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ems="10" >
</EditText>
</LinearLayout>
File Main.java
public class Main extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
EditText et_output = (EditText)findViewById (R.id.et_output);
File file = this.getFilesDir();
String text = "Local storage : " + file.getAbsolutePath();
File[] files = File.listRoots();
for (int i = 0; i < files.length; i++){
String filename = files[i].getAbsolutePath();
filename.replaceAll (new String(new byte[]{0}), "");
File rootFile = new File (filename);
if (file.isDirectory()) {
for (int j = 0; j < rootFile.listFiles().length; j++){
text += rootFile.listFiles() [j].getAbsolutePath() + "rn";
}
}
}
et_output.setText (text);
}
}
Test on your mobile
File_ListRoots
Follow me on my channel PengYooTV …
On my Youku channel
http://i.youku.com/brunoparis
Who am I ?
Bruno Delb (www.delb.cn),
Author of the first french book of development of Java mobile application (2002),
Consultant, project manager and developer of social & mobile applications,
let’s talk about your needs ...
And on Weibo :
http://www.weibo.com/brunodelb

More Related Content

PDF
Build a Searchable Knowledge Base
ZIP
Rails and alternative ORMs
PDF
Find & Locate utility Linux
PPTX
SH 2 - SES 3 - MongoDB Aggregation Framework.pptx
PPTX
Golang slidesaudrey
ODP
One Database To Rule 'em All
PPT
Enterprise Search Solution: Apache SOLR. What's available and why it's so cool
PPTX
Api design and usability
Build a Searchable Knowledge Base
Rails and alternative ORMs
Find & Locate utility Linux
SH 2 - SES 3 - MongoDB Aggregation Framework.pptx
Golang slidesaudrey
One Database To Rule 'em All
Enterprise Search Solution: Apache SOLR. What's available and why it's so cool
Api design and usability

What's hot (20)

PPTX
Solr introduction
PDF
DHWI Linked Open Data - What I Did
PDF
Getting Started with Solr
PPTX
Php File Operations
PDF
Information Retrieval - Data Science Bootcamp
PPT
php file uploading
PDF
scdevsumit 2016 - Become a jedi with php streams
KEY
第49回Php勉強会@関東 Datasource
PDF
03. ElasticSearch : Data In, Data Out
PPT
Day1 search-1
PDF
01 ElasticSearch : Getting Started
PPT
PHP file
PDF
비윈도우즈 환경의 기술 서적 번역 도구 경험 공유
PPTX
Apache Solr - search for everyone!
DOCX
java programming
PDF
Web Scrapping with Python
KEY
Lu solr32 34-20110912
PPT
how google works
PDF
Solr's Search Relevancy (Understand Solr's query debug)
Solr introduction
DHWI Linked Open Data - What I Did
Getting Started with Solr
Php File Operations
Information Retrieval - Data Science Bootcamp
php file uploading
scdevsumit 2016 - Become a jedi with php streams
第49回Php勉強会@関東 Datasource
03. ElasticSearch : Data In, Data Out
Day1 search-1
01 ElasticSearch : Getting Started
PHP file
비윈도우즈 환경의 기술 서적 번역 도구 경험 공유
Apache Solr - search for everyone!
java programming
Web Scrapping with Python
Lu solr32 34-20110912
how google works
Solr's Search Relevancy (Understand Solr's query debug)
Ad

Similar to Android Lab Test : Reading the foot file list (english) (9)

PPTX
Assets, files, and data parsing
PPT
Data Storage In Android
PPTX
Android Lab Test : The views, the Gallery (english)
PDF
03 programmation mobile - android - (stockage, multithreads, web services)
PPTX
Android Data Storagefinal
PPTX
Android File Management Presentation.pptx
PDF
Android datastorage
PPTX
DOCX
2. file internal memory
Assets, files, and data parsing
Data Storage In Android
Android Lab Test : The views, the Gallery (english)
03 programmation mobile - android - (stockage, multithreads, web services)
Android Data Storagefinal
Android File Management Presentation.pptx
Android datastorage
2. file internal memory
Ad

More from Bruno Delb (20)

PPTX
Introduction to Swift (tutorial)
PPTX
Android Lab Test : Storage of data with SharedPreferences (english)
PPTX
Android Lab Test : Using the sensor gyroscope (english)
PPTX
Android Lab Test : Using the network with HTTP (english)
PPTX
Android Lab Test : Managing sounds with SoundPool (english)
PPTX
Android Lab Test : Using the text-to-speech (english)
PPTX
Android Lab Test : Creating a menu dynamically (english)
PPTX
Android Lab Test : Creating a dialog Yes/No (english)
PPTX
Android Lab Test : The styles of views (english)
PPTX
Android Lab Test : Creating a menu context (english)
PPTX
Android Lab Test : Using the camera preview (english)
PPTX
Android Lab Test : Using the WIFI (english)
PPTX
Android Lab Test : Managing the telephone calls (english)
PPTX
Android Lab Test : Reading the SMS-inbox (english)
PPTX
Android Lab Test : Installation of application in Java (english)
PPTX
Android Lab Test : Ecrire un texte sur le canevas (français)
PPTX
Android Lab Test : La connectivité réseau avec HTTP (français)
PPTX
Android Lab Test : Le capteur gyroscope (français)
PPTX
Android Lab Test : Les threads (français)
PPTX
Android Lab Test : L'installation d'une application en Java (français)
Introduction to Swift (tutorial)
Android Lab Test : Storage of data with SharedPreferences (english)
Android Lab Test : Using the sensor gyroscope (english)
Android Lab Test : Using the network with HTTP (english)
Android Lab Test : Managing sounds with SoundPool (english)
Android Lab Test : Using the text-to-speech (english)
Android Lab Test : Creating a menu dynamically (english)
Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : The styles of views (english)
Android Lab Test : Creating a menu context (english)
Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the WIFI (english)
Android Lab Test : Managing the telephone calls (english)
Android Lab Test : Reading the SMS-inbox (english)
Android Lab Test : Installation of application in Java (english)
Android Lab Test : Ecrire un texte sur le canevas (français)
Android Lab Test : La connectivité réseau avec HTTP (français)
Android Lab Test : Le capteur gyroscope (français)
Android Lab Test : Les threads (français)
Android Lab Test : L'installation d'une application en Java (français)

Recently uploaded (20)

PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Cell Structure & Organelles in detailed.
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Business Ethics Teaching Materials for college
PDF
Pre independence Education in Inndia.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
RMMM.pdf make it easy to upload and study
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Complications of Minimal Access Surgery at WLH
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Cell Structure & Organelles in detailed.
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
human mycosis Human fungal infections are called human mycosis..pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Business Ethics Teaching Materials for college
Pre independence Education in Inndia.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
RMMM.pdf make it easy to upload and study
O5-L3 Freight Transport Ops (International) V1.pdf
Renaissance Architecture: A Journey from Faith to Humanism
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Complications of Minimal Access Surgery at WLH
O7-L3 Supply Chain Operations - ICLT Program
PPH.pptx obstetrics and gynecology in nursing
Module 4: Burden of Disease Tutorial Slides S2 2025
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table

Android Lab Test : Reading the foot file list (english)

  • 1. Develop on Android Android Lab Test www.AndroidLabTest.com Youku By Bruno Delb www.weibo.com/brunodelb i.youku.com/brunodelb | www.weibo.com/brunodelb | blog.delb.cn http://i.youku.com/brunoparis Weibo Officialsite Lesson : The list of root directories
  • 2. The list of the root directories • In this lesson, you will learn to use the file manager to list the list of root files. • For this, you will use File and listFiles.
  • 3. The list of the root directories • In order to know the path to the application directory, use the method getFilesDir(). File file = this.getFilesDir(); • In order to know the absolute path to a directory, use the method getAbsolutePath() : String text = "Local storage : " + file.getAbsolutePath();
  • 4. The list of the root directories • To get the list of directories and files at the root, use the method listRoots(). File[] files = File.listRoots();
  • 5. The list of the root directories • To know if an entry of a directory is a directory, use the method isDirectory() : if (file.isDirectory()) { } • To get he list of the files and directories of a directory, use the method listFiles() : rootFile.listFiles()
  • 6. Layout main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <EditText android:id="@+id/et_output" android:layout_width="match_parent" android:layout_height="match_parent" android:ems="10" > </EditText> </LinearLayout>
  • 7. File Main.java public class Main extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); EditText et_output = (EditText)findViewById (R.id.et_output); File file = this.getFilesDir(); String text = "Local storage : " + file.getAbsolutePath(); File[] files = File.listRoots(); for (int i = 0; i < files.length; i++){ String filename = files[i].getAbsolutePath(); filename.replaceAll (new String(new byte[]{0}), ""); File rootFile = new File (filename); if (file.isDirectory()) { for (int j = 0; j < rootFile.listFiles().length; j++){ text += rootFile.listFiles() [j].getAbsolutePath() + "rn"; } } } et_output.setText (text); } }
  • 8. Test on your mobile File_ListRoots
  • 9. Follow me on my channel PengYooTV … On my Youku channel http://i.youku.com/brunoparis Who am I ? Bruno Delb (www.delb.cn), Author of the first french book of development of Java mobile application (2002), Consultant, project manager and developer of social & mobile applications, let’s talk about your needs ... And on Weibo : http://www.weibo.com/brunodelb