cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Tell us what you want to see on the Community here!
Close

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Casting issue

Highlighted

Casting issue

Explorer | Level 4

iam using search builder to search files in my dropbox android app, iam successfully getting filtered searches but iam unable to cast my 

ArrayList<SearchMatch> res;

to

ArrayList<FileMetadata> filterListfiles;

 iam getting my filtered results to res, now i want to send specific index file to download method which receives file metadata object and use that to download that file. iam getting my filtered results but can not be able to cast that 'res' to arraylist filemetadata. any hint would be really appreciateable

below is my code for search

String query2 = query;
Long max = 1000L;
Long stat = 0L;

SearchResult sresult = null;
SearchMode mode = SearchMode.FILENAME;
try {
sresult = client.files().searchBuilder(path2, query2).withMode(mode).withMaxResults(max).withStart(stat).start();
} catch (DbxException e) {
e.printStackTrace();
}
res = (ArrayList<SearchMatch>) sresult.getMatches();

 and this is the method for download

private void downloadFileToStorage(FileMetadata file) {

try {


DownloadFileTask.dwld_Storage = true;
final ProgressDialog dialog = new ProgressDialog(this);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setCancelable(false);
dialog.setMessage("Downloading");
dialog.show();

new DownloadFileTask(MainActivity.this, client, new DownloadFileTask.Callback() {
@Override
public void onDownloadComplete(File result) {
dialog.dismiss();

if (result != null) {
// viewFileInExternalApp(result);
Toast.makeText(context, "Saved", Toast.LENGTH_SHORT).show();
}
}
.
.
.
.
.
.
.

 

1 Reply 1
Highlighted

Re: Casting issue

Explorer | Level 4

I have done it

for (int i = 0 ; i < res.size() ; i++)
{
SearchMatch d = res.get(i);
md = d.getMetadata();
if(md instanceof FileMetadata)
{
String name2 = md.getName();
name3.add(name2);
filterListfiles.add((FileMetadata) md);
}
}

 

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?