S
SljnX
Neues Mitglied
- 0
Hallo hallo
hab etwas in der Forensuche gestöbert, aber leider nichts auf mein wahrscheinlich banales Problem gefunden.
Ich möchte eine Activity aufrufen die auf eine zuvor erstellte Datei zugreift.
Ist die Datei jedoch noch nicht erstellt, wird der Zugriff auf die Activity verneint:
Wie frage ich nun ab, ob die Datei schon besteht? (Wenn sie besteht ist auf jedenfall auch ein Wert in der Datei vorhanden).
Mein bisheriger Code, der leider nicht funktioniert:
Vielen Dank für eure Hilfe!
mfg
[/LEFT]
hab etwas in der Forensuche gestöbert, aber leider nichts auf mein wahrscheinlich banales Problem gefunden.
Ich möchte eine Activity aufrufen die auf eine zuvor erstellte Datei zugreift.
Ist die Datei jedoch noch nicht erstellt, wird der Zugriff auf die Activity verneint:
Wie frage ich nun ab, ob die Datei schon besteht? (Wenn sie besteht ist auf jedenfall auch ein Wert in der Datei vorhanden).
Mein bisheriger Code, der leider nicht funktioniert:
Code:
[SIZE=2]File f = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] File([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"drinklist.txt"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[...]
[SIZE=2][COLOR=#7f0055]
[B][SIZE=2][COLOR=#7f0055]case
[/COLOR][/SIZE][/B][/COLOR][/SIZE][LEFT][SIZE=2]R.id.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]btnListe[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]:[/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2](f.exists())[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][U]intent[/U] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Intent ([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2],DrunkActivity.[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
[SIZE=2]startActivity(intent);[/SIZE]
[SIZE=2]}[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#7f0055]
[/COLOR][/SIZE][SIZE=2]{[/SIZE]
[SIZE=2]Toast t = Toast.[I]makeText[/I]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Es müssen zuerst Getränke ausgewählt werden"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],Toast.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]LENGTH_LONG[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
[SIZE=2]t.show();[/SIZE]
[SIZE=2]}[/SIZE][/LEFT]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]break[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2];[/SIZE]
Vielen Dank für eure Hilfe!
mfg
[/LEFT]