Ordner als Standard Download Ordner setzen

L

Lucius1972

Neues Mitglied
0
Hallo Leute,
Ich lasse den User seinen eigenen download Ordner erstellen den man als standard setzen kann.
Nachdem die Datei runtergeladen ist, ist aber der selbsterstellte Ordner leer und befindet Sie sich im standard ordener mit den Wert "HOME".
Kann mir bitte Jemand hellfen?
Vielen Dank im voraus.

EDIT: geloesst.

Code:
//choose download location//
public void onClick(final View v) {
    switch (v.getId()) {
        case R.id.pick_location_dialog_ok: {
            if (listener != null) {
                final EditText path = (EditText) findViewById(R.id.pick_location_dialog_path);
                final String loc = path.getText().toString();
                listener.onDownloadLocationChanged(loc);
            }
            dismiss();
        }
            break;
        case R.id.pick_location_dialog_cancel: {
            dismiss();
        }
            break;
        case R.id.pick_location_dialog_choose_path: {

            //
        }
            break;
    }
}

//applies onDownloadLocationChanged//
public void onDownloadLocationChanged(final String newLocation) {
    final Settings settings = new Settings(this);
    final String original = settings.getDownloadsLocation();
    if (!newLocation.equals(original)) {
        new File(newLocation).mkdirs();
        settings.setDownloadsLocation(newLocation);

        final SettingsMenuItem item = (SettingsMenuItem) findViewById(R.id.settings_download_location);
        item.setValue(newLocation);

        final AlertDialog.Builder b = new AlertDialog.Builder(this);
        b.setTitle(R.string.app_name);
        b.setMessage(R.string.settings_auto_check_updates);
        b.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

            public void onClick(final DialogInterface dialog, final int which) {
                new MoveFilesTask(SettingsActivity.this, original, newLocation).execute();
                dialog.dismiss();
            }
        });
        b.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {

            public void onClick(final DialogInterface dialog, final int which) {
                dialog.dismiss();
            }
        });
        b.create().show();
    }
}

    }
    //
    //
    //excutes download with choosen path, replace Constants.HOME with chosen download location//
    final File parentDir = new File(Constants.HOME, title);
    if (!parentDir.exists())
        parentDir.mkdirs();
      final File file = new File(parentDir, (filename));
    notification = new ProgressNotification(DownloaderService.this, file);
    super.onStart(intent, startId);

    new Thread() 
    {

public class Constants {
//
public static final File HOME = new File(Environment.getExternalStorageDirectory(),
        "homeloc");
//
}
 
Zuletzt bearbeitet:

Ähnliche Themen

F
  • Fischi84
Antworten
2
Aufrufe
1.916
Fischi84
F
Manny87
  • Manny87
Antworten
11
Aufrufe
164
swa00
swa00
R
  • raller
Antworten
15
Aufrufe
548
DOT2010
DOT2010
Zurück
Oben Unten