里面有详细的文件浏览源代码。大家可以参考下。
不过可惜就是没有文件相关操作,我用了下File,不过对于createNewFile, mkdir等不成功,不知道是什么原因。
具体看源代码吧。
3GEYE(T6wxO
gE/S4sL,c
package org.lombardos.android.FSExplorer1;
import java.io.File;
import java.util.ArrayList;3GEYEc0n Q;`/Y
a
import java.util.List;
import android.app.AlertDialog;3GEYE%y
Z0C$q~hPY(i
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class FileList extends ListActivity {
private List<String> items = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.directory_list);
fill(new File("/").listFiles());
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
int selectionRowID = (int) getSelectionRowID();3GEYENmDuc
d;]L
if (selectionRowID == 0) {
fillWithRoot();
"
l M5]2K
e9t_3 } else {
File file = new File(items.get(selectionRowID));3GEYE
Q&nlmO-r_
if (file.isDirectory())
fill(file.listFiles());
else
AlertDialog.show(this, "Not a Directory",3GEYE
VZ*?/a4{,r
"That's a file, not a directory", "Cancel", false);
}
}
k
QUs@p3X
H-[3 private void fillWithRoot() {
fill(new File("/").listFiles());
}
private void fill(File[] files) {
)^R4a4Q
tP%Bub3 items = new ArrayList<String>();
items.add(getString(R.string.to_top));
for (File file : files)
items.add(file.getPath());
ArrayAdapter<String> fileList = new ArrayAdapter<String>(this,3GEYE*Ty"E/HeN#C"X
z
R.layout.file_row, items);
gcf7W8pl3 setListAdapter(fileList);3GEYEnV
d/zi
I
}
}
9A%ZB'w+q
`fu3/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/3GEYEZTD
}T1yap w
package org.lombardos.android.FSExplorer1;3GEYE
C{${"[s }
public final class R {
!Ty
w)I9j&U7[e3 public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int text1=0x7f050000;
"}4D
s{vT}3 }
public static final class layout {
public static final int directory_list=0x7f030000;
public static final int file_row=0x7f030001;
public static final int main=0x7f030002;
}
public static final class string {
0s c
Wj,q3 public static final int app_name=0x7f040000;
public static final int no_files=0x7f040001;
public static final int to_top=0x7f040002;
}
}
顺便说下
对于File的操作需要具体的权限。
我在Data下面就不可以操作
对于tmp就可以
因为Android是采用linux系统的,所以目录结构下面应该有一个Home,大家可以把数据保存到这里