安卓软件园root精灵文件所有者为0-root意思?

21078人阅读
因项目需要打开文件,因此做了一个打开文件的对话框,现在把这部分的代码共享出来了。
首先是一个回调接口,该接口在文件选择完毕的通知调用者进行如果何种操作。文件接口声明,如下:
// filename: CallbackBundle.java
package com.example.
import android.os.B
// 简单的Bundle参数回调接口
public interface CallbackBundle {
abstract void callback(Bundle bundle);
然后的打开文件对话框的一下封装:
// filename: OpenFileDialog.java
package com.example.
import java.io.F
import java.util.ArrayL
import java.util.HashM
import java.util.L
import java.util.M
import android.app.A
import android.app.AlertD
import android.app.D
import android.content.C
import android.os.B
import android.view.V
import android.widget.AdapterV
import android.widget.ListV
import android.widget.SimpleA
import android.widget.T
import android.widget.AdapterView.OnItemClickL
public class OpenFileDialog {
public static String tag = &OpenFileDialog&;
static final public String sRoot = &/&;
static final public String sParent = &..&;
static final public String sFolder = &.&;
static final public String sEmpty = &&;
static final private String sOnErrorMsg = &No rights to access!&;
// 参数说明
// context:上下文
// dialogid:对话框ID
// title:对话框标题
// callback:一个传递Bundle参数的回调接口
// suffix:需要选择的文件后缀,比如需要选择wav、mp3文件的时候设置为&..mp3;&,注意最后需要一个分号(;)
// images:用来根据后缀显示的图标资源ID。
// 根目录图标的索引为sR
// 父目录的索引为sP
// 文件夹的索引为sF
// 默认图标的索引为sE
// 其他的直接根据后缀进行索引,比如.wav文件图标的索引为&wav&
public static Dialog createDialog(int id, Context context, String title, CallbackBundle callback, String suffix, Map&String, Integer& images){
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setView(new FileSelectView(context, id, callback, suffix, images));
Dialog dialog = builder.create();
//dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setTitle(title);
static class FileSelectView extends ListView implements OnItemClickListener{
private CallbackBundle callback =
private String path = sR
private List&Map&String, Object&& list =
private int dialogid = 0;
private String suffix =
private Map&String, Integer& imagemap =
public FileSelectView(Context context, int dialogid, CallbackBundle callback, String suffix, Map&String, Integer& images) {
super(context);
this.imagemap =
this.suffix = suffix==null?&&:suffix.toLowerCase();
this.callback =
this.dialogid =
this.setOnItemClickListener(this);
refreshFileList();
private String getSuffix(String filename){
int dix = filename.lastIndexOf('.');
if(dix&0){
return &&;
return filename.substring(dix+1);
private int getImageId(String s){
if(imagemap == null){
else if(imagemap.containsKey(s)){
return imagemap.get(s);
else if(imagemap.containsKey(sEmpty)){
return imagemap.get(sEmpty);
private int refreshFileList()
// 刷新文件列表
File[] files =
files = new File(path).listFiles();
catch(Exception e){
if(files==null){
// 访问出错
Toast.makeText(getContext(), sOnErrorMsg,Toast.LENGTH_SHORT).show();
return -1;
if(list != null){
list.clear();
list = new ArrayList&Map&String, Object&&(files.length);
// 用来先保存文件夹和文件夹的两个列表
ArrayList&Map&String, Object&& lfolders = new ArrayList&Map&String, Object&&();
ArrayList&Map&String, Object&& lfiles = new ArrayList&Map&String, Object&&();
if(!this.path.equals(sRoot)){
// 添加根目录 和 上一层目录
Map&String, Object& map = new HashMap&String, Object&();
map.put(&name&, sRoot);
map.put(&path&, sRoot);
map.put(&img&, getImageId(sRoot));
list.add(map);
map = new HashMap&String, Object&();
map.put(&name&, sParent);
map.put(&path&, path);
map.put(&img&, getImageId(sParent));
list.add(map);
for(File file: files)
if(file.isDirectory() && file.listFiles()!=null){
// 添加文件夹
Map&String, Object& map = new HashMap&String, Object&();
map.put(&name&, file.getName());
map.put(&path&, file.getPath());
map.put(&img&, getImageId(sFolder));
lfolders.add(map);
else if(file.isFile()){
// 添加文件
String sf = getSuffix(file.getName()).toLowerCase();
if(suffix == null || suffix.length()==0 || (sf.length()&0 && suffix.indexOf(&.&+sf+&;&)&=0)){
Map&String, Object& map = new HashMap&String, Object&();
map.put(&name&, file.getName());
map.put(&path&, file.getPath());
map.put(&img&, getImageId(sf));
lfiles.add(map);
list.addAll(lfolders); // 先添加文件夹,确保文件夹显示在上面
list.addAll(lfiles); //再添加文件
SimpleAdapter adapter = new SimpleAdapter(getContext(), list, R.layout.filedialogitem, new String[]{&img&, &name&, &path&}, new int[]{R.id.filedialogitem_img, R.id.filedialogitem_name, R.id.filedialogitem_path});
this.setAdapter(adapter);
return files.
public void onItemClick(AdapterView&?& parent, View v, int position, long id) {
// 条目选择
String pt = (String) list.get(position).get(&path&);
String fn = (String) list.get(position).get(&name&);
if(fn.equals(sRoot) || fn.equals(sParent)){
// 如果是更目录或者上一层
File fl = new File(pt);
String ppt = fl.getParent();
if(ppt != null){
// 返回上一层
// 返回更目录
File fl = new File(pt);
if(fl.isFile()){
// 如果是文件
((Activity)getContext()).dismissDialog(this.dialogid); // 让文件夹对话框消失
// 设置回调的返回值
Bundle bundle = new Bundle();
bundle.putString(&path&, pt);
bundle.putString(&name&, fn);
// 调用事先设置的回调函数
this.callback.callback(bundle);
else if(fl.isDirectory()){
// 如果是文件夹
// 那么进入选中的文件夹
this.refreshFileList();
下面是文件条目的一个布局(文件名:filedialogitem.xml):
&?xml version=&1.0& encoding=&utf-8&?&
&LinearLayout xmlns:android=&/apk/res/android&
android:id=&@+id/vw1&
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&
android:background=&#000000&
android:orientation=&horizontal&
android:padding=&4dp& &
&ImageView
android:id=&@+id/filedialogitem_img&
android:layout_width=&32dp&
android:layout_height=&32dp&
android:layout_margin=&4dp&/&
&LinearLayout
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:orientation=&vertical& &
android:id=&@+id/filedialogitem_name&
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&
android:textColor=&#FFFFFF&
android:textSize=&18sp&
android:textStyle=&bold& /&
android:id=&@+id/filedialogitem_path&
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&
android:paddingLeft=&10dp&
android:textColor=&#FFFFFF&
android:textSize=&14sp& /&
&/LinearLayout&
&/LinearLayout&
下面是使用的例子:
// filename: OpenFileDemo.java
package com.example.
import java.util.HashM
import java.util.M
import android.os.B
import android.app.A
import android.app.D
import android.view.V
import android.view.View.OnClickL
public class OpenFileDemo extends Activity {
static private int openfileDialogId = 0;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_open_file_demo);
// 设置单击按钮时打开文件对话框
findViewById(R.id.button_openfile).setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
showDialog(openfileDialogId);
protected Dialog onCreateDialog(int id) {
if(id==openfileDialogId){
Map&String, Integer& images = new HashMap&String, Integer&();
// 下面几句设置各文件类型的图标, 需要你先把图标添加到资源文件夹
images.put(OpenFileDialog.sRoot, R.drawable.filedialog_root); // 根目录图标
images.put(OpenFileDialog.sParent, R.drawable.filedialog_folder_up); //返回上一层的图标
images.put(OpenFileDialog.sFolder, R.drawable.filedialog_folder); //文件夹图标
images.put(&wav&, R.drawable.filedialog_wavfile); //wav文件图标
images.put(OpenFileDialog.sEmpty, R.drawable.filedialog_root);
Dialog dialog = OpenFileDialog.createDialog(id, this, &打开文件&, new CallbackBundle() {
public void callback(Bundle bundle) {
String filepath = bundle.getString(&path&);
setTitle(filepath); // 把文件路径显示在标题上
工程可在我的下载,
放两张效果图:
版权声明:本文为博主原创文章,未经博主允许不得转载。
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:302849次
积分:3931
积分:3931
排名:第4009名
原创:84篇
评论:146条
(1)(3)(3)(2)(2)(2)(1)(1)(2)(4)(2)(1)(3)(1)(1)(3)(2)(1)(2)(2)(1)(5)(12)(2)(2)(5)(2)(5)(7)(2)(4)(6)(3)快捷评论:
自己填写评论
感谢楼主分享!
楼主的大恩大德,小的永记于心!
征集诙谐快捷评论,请去站长问答提交。
需要填写内容!
&登录后可评论资源 ^0^您当前所在位置:
安卓模拟器BlueStacks安装不了apk文件怎么办?
安卓模拟器BlueStacks安装不了apk文件怎么办?
第九软件网
最近发现想要使用安卓模拟器安装电脑中的apk文件不成功,双击apk文件毫无反应,打开方式选择了BlueStacks也没有用,怎么办?在这里小编来教大家解决办法。
最近发现想要使用安卓模拟器安装电脑中的apk文件不成功,双击apk文件毫无反应,打开方式选择了也没有用,怎么办?在这里小编来教大家解决办法。
BlueStacks无法安装应用解决办法
1.其实方法很简单,右键单击桌面保存好的apk文件,选择打开方式,选择默认程序。浏览其他程序。
2.找到c盘中如图所示的应用路径(c盘---ProgramFiles---BlueStacks---&HD-ApkHandler.exe)选中&ApkHandler.exe&确定。
3.接下来就恢复正常了,apk文件可以正常安装到安卓模拟器中了。
第九小编亲测有用哦!
转载请注明出处:第九软件网
安卓模拟器下载:
软件名称:安卓模拟器(BlueStacks)0.7.13.899中文版
大小:109.89MB版本:0.7.13.899中文版类别:杂类工具
语言:中文使用平台:Win_xp/Win7/Win8/Ubuntu
关键词标签:
延伸相关阅读:
第九专题推荐
每周酷软推荐
一款电脑系统重装软件
小黑马系统重装大师是一款简单好用的电脑系统重装软件,小黑马一键...
第九软件教程推荐请问Linux 命令 ls -l 后出现的是什么意思_百度知道
请问Linux 命令 ls -l 后出现的是什么意思
请高手帮忙解决& 些行&都意思
提问者采纳
看,用ls -l命令查看某目录9字段列表.####################### 第1行:总用量(total) ####################### 数值该目录所文件及目录列表第5字段(k单位),该目录.请注意该目录文件目录文件总合做区.数字du /root 数字.用awk命令验证.用awk累加第5字段数值:[root@gucuiwen root]# ls -l |awk &#39;BEGIN{sum=0}{sum+=$5}END{print sum}&#39; 4104092转化K单位:[root@gucuiwen root]# ls -l |awk &#39;BEGIN{sum=0}{sum+=$5}END{print sum/1024}&#39; 4007.9用ls -l数值: 总用量 4055用du -sh /root数值: [root@gucuiwen root]# du -sh /root 127M /root看累加第5字段值total显示(具体算同,略微差别).数值实际root目录(root目录看特殊文件,理解目录).用du数值root目录所由文件目录全部文件总合.######################## 第1字段: 文件属性字段 ########################文件属性字段总共10字母组,第字母表示文件类型,字母减号&-&,则说明该文件普通文件.字母&d&表示该文件目录,字母&d&,dirtectory(目录)缩写.请注意,目录或者说文件夹特殊文件,特殊文件存放其文件文件夹相关信息.该字母&l&,表示该文件符号链接.符号链接概念类似于windows快捷式.字母&l&link(链接)缩写.UNIX类系统,文件文件名,文件文件名间互称硬链接(hard link).些文件指向同文件,删除其文件名并能删除该文件,指向该文件所硬链接都删除,文件所占用空间才真释放,该文件才真删除.windows区别,windows允许文件两文件名,存情况,则认文件系统错误.前windows玩DEBUG知道,用DEBUG修改张软盘根目录,使文件同具两文件名.修改用 scandisk监测候认交叉链接错误.b表示块设备文件(block),,设备文件普通文件程序访问硬件设备入口,特殊文件.没文件,主设备号辅设备号.面hda1设备文件,具主设备号3辅设备号1.表示第硬盘第区.另外,第字母c表示该文件字符设备文件(character),传输字节设备称字符设备,比键盘,字符终端等,传输数据单位字节.传输数据整块称块设备,比硬盘,光盘等.数据传输单位数据块(通数据块512字节).第字段面9字母表示文件权限. r表读 (Read) w表示写 (Write) x表示执行 (eXecute)其前三表示文件属主权限,间三表示组用户权限,三表示其用户权限. 比:-rw-r--r-- 1 root root 1581 11月 24 18:14 anaconda-ks.cfg表示文件拥者root文件读写权限,其(同组用户其用户读权限)另外,权限组些特殊表示.比/usr/X11R6/bin/XFree86具权限:[root@gucuiwen root]# ll /usr/X11R6/bin/XFree86 -rws--x--x 1 root root 3-02-28 /usr/X11R6/bin/XFree86其s表示网络接口程序&s&socket缩写.该程序运行程打网络接口.其UNIX类系统FreeBSDt权限,表示临(temporary)文件 freeBSD用ls -l /tmp 看权限: drwxrwxrwt 位字母&t&############################### 第2字段 文件硬链接数或目录目录数 ###############################文件目录字段表示,文件所具硬链接数,即文件总共少文件名.查看第文件:-rw-r--r-- 1 root root 1581 11月 24 18:14 anaconda-ks.cfg第2字段值1,说明文件anaconda-ks.cfg文件名.即指向该链接硬链接. 我用ln,做指向该文件硬链接再查看该文件,该文件第2字段变<img class="word-replace" src="/api/getdecpic?picenc=0a5f:[root@gucuiwen root]# ln anaconda-ks.cfg anaconda-ks.cfg.hardlink [root@gucuiwen root]# ls -l 总用量 4071 -rw-r--r-- 2 root root 1581 11月 24 18:14 anaconda-ks.cfg -rw-r--r-- 2 root root 1581 11月 24 18:14 anaconda-ks.cfg.hardlink,anaconda-ks.cfg anaconda-ks.cfg.hardlink 称互硬链接.指向同文件,论修改哪文件,另做相应变化,实际指向同文件.用ls -i anaconda-ks.cfg查看文件节点(inode) 互硬链接文件具相同文件节点. 验证实验:[root@gucuiwen root]# ls -i anaconda-ks.cfg 18102 anaconda-ks.cfg [root@gucuiwen root]# ls -i anaconda-ks.cfg.hardlink 18102 anaconda-ks.cfg.hardlink看,两文件具相同文件节点号:18102知道文件文件名,何查找其文件名布呢?先用ls -i 获节点号,用find查找,/etc/sysconfig/networking/devices/ifcfg-eth0具文件名,我要查找与互硬链接文件:[root@gucuiwen devices]# ls -i /etc/sysconfig/networking/devices/ifcfg-eth0 147181 /etc/sysconfig/networking/devices/ifcfg-eth0节点号 147181 再用find查找:[root@gucuiwen devices]# find /etc -inum 147181 /etc/sysconfig/networking/devices/ifcfg-eth0 /etc/sysconfig/networking/profiles/default/ifcfg-eth0同文件同文件名位置.************************************* 目录,第2字段含义: **************************************目录,则第2字段表示该目录所含目录数. 新建空目录,目录第二字段2,表示该目录两目录.新建目录面两目录呢? 每目录都指向本身目录&.& 指向级目录目录&..&,两默认目录隐藏.用ls -a看.每目录新建目录,该目录第2字段值增1,新建普通文件该字段值增加.############################### 第3字段: 文件拥者 ###############################该字段表示文件属于哪用户.UNIX类系统都用户系统,每文件都拥者.文件拥者才具改文件属性权利., root用户具改任何文件属性权利.于目录说,拥该目录用户,或者具写权限用户才目录创建文件权利.某用户某种原,删除,该用户文件存,用ls -l 查看该文件显示代表用户存前ID号数字.演示:先创建用户并用su:[root@gucuiwen root]# useradd gucuiwen -g users [root@gucuiwen root]# su - gucuiwen用新建用户创建测试文件:[gucuiwen@gucuiwen gucuiwen]$ touch testfile [gucuiwen@gucuiwen gucuiwen]$ ls -l testfile -rw-r--r-- 1 gucuiwen users 0 1月 4 16:31 testfile用ls -l 看第三字段文件拥者gucuiwen我gucuiwen用户删除:[root@gucuiwen root]# userdel gucuiwen [root@gucuiwen root]# cd /home/gucuiwen/ [root@gucuiwen gucuiwen]# ls -l 总用量 0 -rw-r--r-- 1 501 users 0 1月 4 16:31 testfile看,第三字段数字,数字原gucuiwen用户ID号.文件系统每文件记录文件所者ID,非用户名.############################### 第4字段: 文件拥者所组 ###############################组概念想像共同完项目团队.通组概念,控制文件让特定用户查看,修改或运行.棍打死,要全让看,要全让看.用户加入组,其主组,显示第4字段明称.adduser候用-g指定该用户所主组,用-G指定其组.############################### 第5字段: 文件文件(字节单位) ###############################第5字段表示文件,文件夹,则表示该文件夹.请注意文件夹本身,文件夹及面文件总! 能理解文件夹特殊文件含义,理解文件夹含义比较困难.############################### 第6字段: 文件创建月份 ############################### 必说.############################### 第7字段: 文件创建期 ############################################################## 第8字段: 文件创建间 ############################### 文件创建间通touch命令修改.: #touch testfile testfile创建间修改前间. touch详细用请看链接文档. #man touch另外,文件访问间,修改间等属性. 些属性用ls 其参数显示.############################### 第9字段: 文件名 ###############################符号链接, &-&& 箭符号,面根指向文件名.
提问者评价
来自团队:
其他类似问题
为您推荐:
其他5条回答
蓝色文件夹 第列其权限r读x执行w写 第二列数字其连接数 第三列 拥者 第四列所工作组 第五列(kb) 面创建修改间面文件名
前面的rwx代表的是这些文件的权限 r :可读,w:可写,w:可执行root
就是根目录了,其他的就是时间和文件名了
-rw-r--r--
1 user root
1022 Feb 13 16:07 anaconda-ks.cfg这些都是文件的属性,包括文件(-)、:1)(user)的权限为rw-、拥有读和写,2)组(root):r--,拥有读权限3)其他成员,r--,拥有读权限 4)122表示文件的大小,5)Feb 13 16:07是文件的修改时间。
这些都是当前目录下的文件和目录名列表.这个列表包含了文件的属性,所属用户,所属组,创建时间,文件大小等等信息.具体说明参考: PS:能自己了解的东西,最后自己找。。动手才重要!
建议买本Linux书学习..
您可能关注的推广回答者:
linux的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 安卓软件园root精灵 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信