Android 浏览和上传功能在安卓系统中有效吗?

Android 浏览和上传功能在安卓系统中有效吗?,android,cordova,file-upload,Android,Cordova,File Upload,我有一个应用程序,其中有一个按钮浏览,onclick可以打开android手机中存在的所有文件和文件夹。我有一个疑问,这是可能的浏览和选择文件上传?我注意到由于安全原因,在android中不起作用。有谁能给我看一些关于如何从手机浏览文件以上传的好例子吗?以下是完整的代码: AndroidExplorer.class public class AndroidExplorer extends ListActivity { private List<String> item = null

我有一个应用程序,其中有一个按钮浏览,onclick可以打开android手机中存在的所有文件和文件夹。我有一个疑问,这是可能的浏览和选择文件上传?我注意到由于安全原因,
在android中不起作用。有谁能给我看一些关于如何从手机浏览文件以上传的好例子吗?

以下是完整的代码:

AndroidExplorer.class

public class AndroidExplorer extends ListActivity {

private List<String> item = null;
private List<String> path = null;
private String root="/";
private TextView myPath;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    myPath = (TextView)findViewById(R.id.path);
    getDir(root);
}

private void getDir(String dirPath)
{
    myPath.setText("Location: " + dirPath);

    item = new ArrayList<String>();
    path = new ArrayList<String>();

    File f = new File(dirPath);
    File[] files = f.listFiles();

    if(!dirPath.equals("/"))
    {

        item.add(root);
        path.add(root);

        item.add("../");
        path.add(f.getParent());

    }

    for(int i=0; i < files.length; i++)
    {
            File file = files[i];
            path.add(file.getPath());
            if(file.isDirectory())
                item.add(file.getName() + "/");
            else
                item.add(file.getName());
    }

    ArrayAdapter<String> fileList =
        new ArrayAdapter<String>(this, R.layout.row, item);
    setListAdapter(fileList);
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {

    File file = new File(path.get(position));

    if (file.isDirectory())
    {
        if(file.canRead())
            getDir(path.get(position));
        else
        {
            new AlertDialog.Builder(this)
            .setIcon(R.drawable.icon)
            .setTitle("[" + file.getName() + "] folder can't be read!")
            .setPositiveButton("OK", 
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                        }
                    }).show();
        }
    }
    else
    {
        new AlertDialog.Builder(this)
            .setIcon(R.drawable.icon)
            .setTitle("[" + file.getName() + "]")
            .setPositiveButton("OK", 
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                        }
                    }).show();
    }
}
}
公共类AndroidExplorer扩展了ListActivity{
私有列表项=null;
私有列表路径=null;
私有字符串root=“/”;
私有文本视图myPath;
/**在首次创建活动时调用*/
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myPath=(TextView)findViewById(R.id.path);
getDir(根);
}
私有void getDir(字符串dirPath)
{
setText(“位置:“+dirPath”);
item=newarraylist();
路径=新的ArrayList();
文件f=新文件(dirPath);
File[]files=f.listFiles();
如果(!dirPath.equals(“/”)
{
项。添加(根);
添加(根目录);
项目.添加(“/”);
add(f.getParent());
}
对于(int i=0;i
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"
>
<TextView
android:id="@+id/path"
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
/>
<TextView
android:id="@android:id/empty"
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="No Data"
/>
</LinearLayout>


因为我以前没有使用过PhoneGap,所以我希望这能给你一些建议…@SheIs_LeThiCongNhan谢谢我会浏览你指定的链接。不客气:-)很遗憾,我无法帮助你使用PhoneGap。关于你的目标,据我所知,你不需要任何权限。我已找到PhoneGap的文件选择器。您好,谢谢您的快速响应。我将查看您附加的代码。但是我正在研究phonegap,所以你有没有关于如何使用phonegap浏览文件的示例?对不起,兄弟..我还没有研究过phonegap!