2012-03-03 9 views
14

का उपयोग कर ड्रॉपबॉक्स के सभी फ़ोल्डर और फ़ाइलों की सूची सूची में सभी फाइलों और फ़ोल्डर को प्रदर्शित करने के लिए ट्यूटोरियल की तलाश है .. लेकिन मुझे कुछ भी नहीं मिला .. क्या किसी को यहां पता है कि मैं सभी को कैसे दिखा सकता हूं ड्रॉपबॉक्स के फ़ोल्डर और फाइलें मेरी सूचीदृश्य में .. इसलिए जब मैं किसी भी फ़ाइल पर क्लिक करता हूं .. तब वह फ़ाइल डाउनलोड शुरू होती है ..ड्रॉपबॉक्स एपीआई

अच्छी तरह से मुझे पता है कि ड्रॉपबॉक्स से फ़ाइल कैसे डाउनलोड करें, लेकिन इसके लिए मुझे अपने कोड में एक स्थिर तरीके से फ़ाइल का नाम रखना होगा ..

मैं बाद में .csv फ़ाइल के लिए फ़िल्टर का उपयोग करने जा रहा हूं ... लेकिन मैं सभी फ़ाइलों को एक सूचीदृश्य में दिखाना चाहता हूं।

धन्यवाद ..

+0

मुझे भी एक ही जरूरत है .. –

उत्तर

20
  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; 

यह मैं क्या उपयोग है। एक बार आप stringarray fnames है, तो आप यह सूचीदृश्य में प्रदर्शित कर सकते हैं।

आप इस

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; 
        } 

        }); 
+0

क्या MAPI here.Can तुम मुझे नमूना डेमो प्रदान करना है। – shailesh

+0

@AmelJose क्या मैं यहाँ है? – NarendraJi

+0

@shailesh AppKeyPair appKeys = नए AppKeyPair (APP_KEY, APP_SECRET); AndroidAuthSession सत्र = नए AndroidAuthSession (appKeys); DropboxAPI MAPI = नए DropboxAPI <> (सत्र); – NarendraJi

3

फ़ाइलों की सूची के लिए इस कोड का प्रयास करें ..... मैं ड्रॉपबॉक्स के बारे में अधिक पता नहीं है, कोशिश यह

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

    List<Entry> CFolder = contact.contents; 
    for (Entry entry : CFolder) { 
    Log.i("DbExampleLog", "Filename: " + entry.fileName());} 
+0

क्या है mDBApi स्पष्ट या डेमो परियोजना – shailesh

+0

@shailesh मैं अपने देर से पता के लिए किसी भी लिंक दे कृपया: DropboxAPI mDBApi – Lunchbox

-1

की तरह एक gridview में प्रदर्शित इस एक का उपयोग करें कर सकते हैं यह नवीनतम एपीआई है .....

public void login(String accessToken) { 
     DbxRequestConfig requestConfig = DbxRequestConfig.newBuilder("ManualApp") 
       .withHttpRequestor(OkHttp3Requestor.INSTANCE) 
       .build(); 
     mDbxClient = new DbxClientV2(requestConfig, accessToken); 
    } 

    public List<Metadata> getListFile(String path) { 

     if (mDbxClient == null) { 
      RkLogger.e("get files error", "must login first please"); 
      return null; 
     } 

     try { 
      return mDbxClient.files().listFolder(path).getEntries(); 
     } catch (DbxException e) { 
      RkLogger.e("DbxException ", e.toString()); 
      return null; 
     } 

    } 
संबंधित मुद्दे