Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all the folder and files of Dropbox using Dropbox API

Am looking for the tutorial to display all the files and folder in a listview..but I didn't get anything..Does anyone here know that how can I show all the folder and files of Dropbox into my listview..So that when I click on any of the file..Then that file starts download..

Well I know here that How to download a file from Dropbox, but for that I need to put that name of the file in my code in a static way..

I am also going to use filter afterwards for .csv file only...but I want to show all the files in a listview.

Thanks..

like image 616
Kanika Avatar asked Mar 03 '12 12:03

Kanika


People also ask

How do I get a list of files in Dropbox folder?

Just open Dropbox.com, and select the Shared button in the left sidebar. You will see all of your shared folders and files, along with the time they were last modified. Note that this shows both shared folders you've added to your Dropbox and folders that you have access to but haven't added.

How do I see all folders in Dropbox?

See all of your shared Dropbox files and folders Just go to dropbox.com/share—or click Shared in the Dropbox web app sidebar. There, you'll see all of your shared files and folders and can edit any of them directly.

How do I see how many files are in Dropbox?

If it's the Dropbox website, select all the files in the folder and the count will be shown in the upper right.


2 Answers

            String[] fnames = null;
            Entry dirent = mApi.metadata("/", 1000, null, true, null);
            ArrayList<Entry> files = new ArrayList<Entry>();
            ArrayList<String> dir=new ArrayList<String>();
            for (Entry ent: dirent.contents) 
            {
                files.add(ent);// Add it to the list of thumbs we can choose from                       
                //dir = new ArrayList<String>();
                dir.add(new String(files.get(i++).path));
            }
            i=0;
            fnames=dir.toArray(new String[dir.size()]);

            return fnames;

This is what i use. once you have stringarray fnames,you can display it in a listview.

You can display it in a gridview like this

final GridView gv=(GridView)temp.findViewById(R.id.gridView1);
ArrayAdapter<String> ad = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1,fnames);
gv.setBackgroundColor(Color.BLACK);
gv.setNumColumns(3);
gv.setGravity(Gravity.CENTER);
gv.setAdapter(ad);
    gv.setBackgroundResource(R.drawable.black_cloud1);
gv.setOnItemClickListener(new OnItemClickListener() {
                    public void onItemClick(AdapterView<?> arg0, View arg1,
                            int arg2, long arg3) {
                        // TODO Auto-generated method stub
                        Toast.makeText(mContext,gv.getItemAtPosition(arg2).toString(),Toast.LENGTH_SHORT).show();

                        temp.setData(fnames,gv.getItemAtPosition(arg2).toString());

                        return;
                    }

                    });
like image 52
Amel Jose Avatar answered Sep 24 '22 13:09

Amel Jose


Try this code to list the files.....I don't know more about Dropbox, try it

 Entry contact = mDBApi.metadata("/", 0, null, true, null);

    List<Entry> CFolder = contact.contents;
    for (Entry entry : CFolder) {
    Log.i("DbExampleLog", "Filename: " + entry.fileName());}
like image 39
Hari Avatar answered Sep 26 '22 13:09

Hari