Android Kann nicht mehr auf SDCard schreiben

achilles

Mitglied
Meine Anwendung kann auf einem Motorola Defy nicht mehr auf die SDCard schreiben: auf einem HTC Desire und einem HTC Legend sowie einem Motorola Milestone funktioniert es. Auf dem Defy anfangs auch. Doch ohne erkennbaren Grund funktioniert es jetzt auf dem Defy nicht mehr.

Der Code ist folgender:
Java:
_imageFile = new File(path);
if (!_imageFile.exists()) {
    Log.v(TAG, "Create image file " + path);
    if (!_imageFile.getParentFile().mkdirs()) {
        Log.v(TAG, "Unable to create dirs.");
    }
    try {
        _imageFile.createNewFile();
    } catch (IOException e) {
        Log.v(TAG, "IOException: " + e.toString());
    } catch (SecurityException e) {
        Log.v(TAG, "SecurityException: " + e.toString());
    }
} else {
    Log.v(TAG, "image file already created.");
}

Der Code wirft eine IOException mit dem Hinweis, dass die Datei nicht erstellt werden kann. Aber warum nicht?
Auf der SDCard ist ausreichend Platz, ich kann auch über den FileBrowser von DDMS Dateien anlegen und auf allen anderen Geräten funktioniert es ebenfalls.

Hat irgendjemand eine Ahnung, woran das liegen könnte?
 

achilles

Mitglied
@diel2001: ja, das entsprechende Recht habe ich im Manifest gesetzt - wie gesagt: im Emulator und auf anderen Geräten funktioniert es auch.

@mjdv: ja, das prüfe ich (sorry, das hatte ich nicht im Codeschnippsel, den ich am Anfang eingefügt hatte drin):

Java:
public void onClickTakePicture(final View v) {
    String storageState = Environment.getExternalStorageState();
    Log.v(TAG, "StorageState = " + storageState);
    if (storageState.equals(Environment.MEDIA_MOUNTED)) {
        mImage = new Image(this, mDb, _id);
        String path = Image.SD_IMAGE_DIR + "/" + mImage.fileName;
        _imageFile = new File(path);
        if (!_imageFile.exists()) {
            Log.v(TAG, "Create image file " + path);
            _imageFile.getParentFile().mkdirs();
            try {
                _imageFile.createNewFile();
            } catch (IOException e) {
                Log.e(TAG, "IOException: " + e.toString());
            }
        } else {
            Log.v(TAG, "image file already created.");
        }
        if (!_imageFile.canWrite()) {
            Log.e(TAG, "Can't write to File.");
        }

        cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri
                .fromFile(_imageFile));
        try {
            startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
            Log.v(TAG, "Start Activity 'ImageCapture'");
        } catch (Exception e) {
            Log.e(TAG, "Exception while capturing image: " + e.toString());
        }
    } else {
        Log.v(TAG, "SDCard not mounted.");
        Toast.makeText(this, "SDCard not mounted.", Toast.LENGTH_LONG)
                .show();
    }
}

Log.v() in der zweiten Zeile der Methode gibt im LogCate "StorageState = mounted" aus.

Ich habe am Wochenende noch mal ein wenig herumprobiert: wenn ich in das betreffende Gerät eine andere SDCard einsetze, funktioniert es. Ich habe daraufhin von der alten Karte ein Backup gemacht, die Karte formatiert und das Backup zurückgespielt - wieder das gleiche Problem. Ich werde heute mal schauen, ob ich mit der betreffenden Karte das selbe Problem in einem anderen Gerät habe.

Gibt es für Android eigentlich eine Art fsck?
 

achilles

Mitglied
Ich habe die betreffende SDCard jetzt mal in einem anderen Gerät ausprobiert: dort funktioniert es auch nicht, allerdings kriege ich eine etwas aussagekräftigere Fehlermeldung:
Code:
IOException: java.io.IOException: No space left on device
.

Eigentlich sollte noch 1GB frei sein ???:L

Vermutlich ist also die Karte defekt - aber warum kann ich dann trotzdem regulär Bilder machen oder Datei auf das Gerät kopieren?
 

achilles

Mitglied
Ich dachte, ich hätte das Problem durch einen Wechsel der SD-Karte gelöst.
Mittlerweile habe ich noch zwei weitere DEFY und siehe da: das selbe Phänomen. Nach einer gewissen Zeit - wenn die Karte etwa zu 50% voll ist - wirft die Anwendung eine IOException ... ???:L

Bei dem ersten Gerät dachte ich ja noch, die SD-Karte wäre irgendwie defekt. Eigentlich wollte ich ja noch 10 weitere DEFY bestellen - aber wenn ich bei drei Geräten dieses merkwürdige Problem habe und bei allen anderen Geräten (HTC Desire, HTC Legend, Motorola Milestone) dieses Problem nicht auftritt, schrecke ich davor zurück...

Hat vielleicht irgendjemand ein ähnliches Problem mit dem DEFY?
 

achilles

Mitglied
Problem gelöst!!!

Ich habe endlich herausgefunden, wieso ich auf der Karte keine weiteren Dateien mehr speichern kann, obwohl noch genug Platz vorhanden ist: das Defy wird mit einer 2GB-Karte geliefert und diese scheint mit FAT16 formatiert zu sein - die Folge: man kann im Hauptverzeichnis (und dort speichere ich die Dateien) maximal 512 Dateien abgelegt werden. Da ich lange Dateinamen verwende und deshalb pro Datei mehrere Einträge "verschwendet" werden, war bei mir schon mit ca. 130 Dateien Schluss...

Die 4GB-Karte ist mit FAT32 formatiert und dort gibt es diese Beschränkung nicht.

Also, Thema abgeschlossen.
 
M

maki

Gast
das Defy wird mit einer 2GB-Karte geliefert und diese scheint mit FAT16 formatiert zu sein
WOW!

Sony lieferte also seine handys mit SD Karten aus, die in einem absolut zeitgemässen Dateisystem formatiert war, FAT16 ist ja auch erst von 1983...:autsch:
 

achilles

Mitglied
Motorola, nicht Sony.

Aber ja, ich hätte auch nicht gedacht, dass ich jetzt noch mal über dieses uralte Problem stolpere. Vor ein paar Jahren wäre ich bestimmt auch schneller darauf gekommen, woran es liegt...
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
W AlertDialog Eigenschaften existiert nicht mehr. Android & Cross-Platform Mobile Apps 14
J Service starte nicht mehr Android & Cross-Platform Mobile Apps 13
M Notification nicht mehr senden nachdem sie geklickt wurde Android & Cross-Platform Mobile Apps 0
J Handy bootet nicht mehr richtig Android & Cross-Platform Mobile Apps 2
W Eclipse update - Systemprozess reagiert nicht mehr Android & Cross-Platform Mobile Apps 4
U Seit heute morgen läuft meine OpenGL app nicht mehr Android & Cross-Platform Mobile Apps 2
B Java ME Kann mein Projekt nicht mehr ausführen? Android & Cross-Platform Mobile Apps 5
W MoveEvent reagiert nicht Game Android & Cross-Platform Mobile Apps 1
W Reward Ads AdMob wird nicht ausgeliefert. Android & Cross-Platform Mobile Apps 9
W Cookie Manger übermittelt nicht Android & Cross-Platform Mobile Apps 1
J Spinner wird nicht aktualisiert Android & Cross-Platform Mobile Apps 6
M PythonInterpreter funktioniert nicht richtig NoClassDefFoundError Android & Cross-Platform Mobile Apps 1
I Android SharedPreferences wenn App auf externem Speicher klappt nicht Android & Cross-Platform Mobile Apps 0
W Frisch generiertes Projekt Value nicht findbar NavController Drawer Android & Cross-Platform Mobile Apps 12
ImageView wird nicht angezeigt Android & Cross-Platform Mobile Apps 4
W WebView Linkvertise lädt nicht richtig oder bleibt grau Android & Cross-Platform Mobile Apps 10
W Wieso gehen Log nicht im Service? Android & Cross-Platform Mobile Apps 20
R Android Do not disturb: Sound wird nicht abgespielt Android & Cross-Platform Mobile Apps 2
O Google Admob Ad wird nicht geladen und App stürzt ab Android & Cross-Platform Mobile Apps 1
I Android ListView (Custom) soll auf Hardwaretasten nicht reagieren. Android & Cross-Platform Mobile Apps 10
CT9288 Zufällige Zahlengenerierung scheint nicht richtig zu funktionieren Android & Cross-Platform Mobile Apps 5
M App crasht und ich bekomme es nicht behoben.:( Android & Cross-Platform Mobile Apps 17
M Paper DB wird in Android Studio nicht erkannt Android & Cross-Platform Mobile Apps 7
K Android Android In-App-Purchase lädt nicht Android & Cross-Platform Mobile Apps 0
Besset Android http request an interne ip adresse funktioniert nicht Android & Cross-Platform Mobile Apps 8
R Android Visualizer engine kann nicht initialisiert werden Android & Cross-Platform Mobile Apps 3
OSchriever Navigation drawer Strings ändern sich nicht Android & Cross-Platform Mobile Apps 0
W Code läuft unter SDK 27 aber nicht SDK 30 Android & Cross-Platform Mobile Apps 17
N Android Ich kann mit meiner App nicht auf die Datenbank zugreifen Android & Cross-Platform Mobile Apps 4
A GraphView => X- und Y-Achse wird nicht angezeigt Android & Cross-Platform Mobile Apps 5
ruutaiokwu Android Selbst entwickelter SMTP-Client läuft auf PC, nicht aber auf Android Android & Cross-Platform Mobile Apps 9
W Android Wieso geht getApplicationContext() bei Toast, aber nicht bei AlertDialog.Builder? Android & Cross-Platform Mobile Apps 36
A Android Studio: while-Schleife beginnt nicht Android & Cross-Platform Mobile Apps 5
A jpg wird im Android Studio nicht akzeptiert Android & Cross-Platform Mobile Apps 3
T Android SDK-Manager startet nicht in Eclipse Android & Cross-Platform Mobile Apps 5
J Download und speichern mit jsch klappt nicht Android & Cross-Platform Mobile Apps 5
Arif Android Radiobutton wird nicht deaktiviert Android & Cross-Platform Mobile Apps 1
Arif Android Canvas wird nicht gezeichnet? Android & Cross-Platform Mobile Apps 0
J Notification wird nicht angezeigt wenn App nicht offen ist. Android & Cross-Platform Mobile Apps 6
J Firebase und Emulator startet nicht Android & Cross-Platform Mobile Apps 2
L ListView aktuallisiert sich nicht Android & Cross-Platform Mobile Apps 15
J ArrayAdapter zeigt Liste nicht an Android & Cross-Platform Mobile Apps 0
L Android Animationen werden nicht angezeigt Android & Cross-Platform Mobile Apps 0
Excess Android Service läuft nicht in Sandby weiter Android & Cross-Platform Mobile Apps 2
W Preview wird nicht korrekt angezeigt Android & Cross-Platform Mobile Apps 0
B Profilpic wird nach anmeldung nicht angezeigt. Android & Cross-Platform Mobile Apps 2
K Methode wird nicht gefunden Android & Cross-Platform Mobile Apps 1
J App funktioniert auf Android 5, auf 6 nicht Android & Cross-Platform Mobile Apps 2
K Log.v geht nicht Android & Cross-Platform Mobile Apps 4
J Kamera - Foto wird nicht gespeichert Android & Cross-Platform Mobile Apps 2
L Android Android Studio - Exportierte APK funktioniert nicht Android & Cross-Platform Mobile Apps 6
L Android Methode funktioniert nicht unter Android Android & Cross-Platform Mobile Apps 3
L Android Java scheint XML nicht zu finden Android & Cross-Platform Mobile Apps 11
J android Spinner funktioniert nicht Android & Cross-Platform Mobile Apps 14
B Android osmdroid möchte nicht das es mapnik herunterlädt Android & Cross-Platform Mobile Apps 2
apple_pie1998 SharedPreferences funktionieren nicht... Android & Cross-Platform Mobile Apps 17
S Android neue Version des Programms wird nicht in Emulator geladen Android & Cross-Platform Mobile Apps 1
B Android Textdatei laden (klappt nicht) Android & Cross-Platform Mobile Apps 4
O Android Switch Widget wird nicht angezeigt Android & Cross-Platform Mobile Apps 1
M Android ListView wird nicht dargestellt Android & Cross-Platform Mobile Apps 2
S Android null pointer (ich verstehs nicht) Android & Cross-Platform Mobile Apps 2
S Android Emulator startet nicht vollständig. Android & Cross-Platform Mobile Apps 0
S Neue Activity lässt sich nicht starten Android & Cross-Platform Mobile Apps 28
D Android Tabs nutzen - PagerTitleStrip haut nicht hin Android & Cross-Platform Mobile Apps 4
K MediaPlayer Soundklasse Start und Stop (stop funktioniert nicht) Android & Cross-Platform Mobile Apps 1
O Android Anfänger: Quellcode nicht gefunden Android & Cross-Platform Mobile Apps 3
B Timer geht nicht Android & Cross-Platform Mobile Apps 2
S Umlaute werden trotz UTF-8 nicht angezeigt? Android & Cross-Platform Mobile Apps 6
S SPLIT funktion bei STRING funktioniert nicht! Android & Cross-Platform Mobile Apps 4
J Android Breaking Point in Eclipse hält nicht an? Android & Cross-Platform Mobile Apps 5
J Android SimpleDateFormat parser funktioniert nicht richtig? Android & Cross-Platform Mobile Apps 4
L Android Apache POI: Datei speichern geht nicht Android & Cross-Platform Mobile Apps 1
Y Erstes kleines Android Programm will nicht so recht... Android & Cross-Platform Mobile Apps 1
S Foto-app hält galerie nicht aktuell Android & Cross-Platform Mobile Apps 9
D Man sieht nicht ob Button gedrückt wurde! Android & Cross-Platform Mobile Apps 10
L Android Multitouch will einfach nicht, was mach ich falsch? Android & Cross-Platform Mobile Apps 1
B AlarmManager triggert nicht jede Stunde Android & Cross-Platform Mobile Apps 7
B Erste Android-App: setContentView(R.layout.main) funktioniert nicht Android & Cross-Platform Mobile Apps 6
N Android EditText.setError() funktioniert nicht nach Rotation Android & Cross-Platform Mobile Apps 1
K OnItemLongClickListener in ListActivity spricht nicht an Android & Cross-Platform Mobile Apps 8
N Android Display nicht löschen bzw. neu laden Android & Cross-Platform Mobile Apps 2
D Android OnClickListener funktioniert auf LinearLayout nicht Android & Cross-Platform Mobile Apps 6
X Android Warum werden Views nicht gefunden? Android & Cross-Platform Mobile Apps 4
D Android App startet nicht Android & Cross-Platform Mobile Apps 24
F Android ArrayList nicht funktional in Android!? Android & Cross-Platform Mobile Apps 6
E Datenbankanfrage findet Tabel nicht Android & Cross-Platform Mobile Apps 3
S Android LogCat Ausgaben in Schleife geht nicht? Android & Cross-Platform Mobile Apps 2
schlingel Android Warum man Apps beenden sollte bzw. es nicht tun sollte Android & Cross-Platform Mobile Apps 4
S Auflösungsanpassung funktioniert nicht Android & Cross-Platform Mobile Apps 2
P trotz invalidate() wird onDraw() nicht aufgerufen Android & Cross-Platform Mobile Apps 15
A Werde aus Fehlermeldung nicht schlau.... :-( Android & Cross-Platform Mobile Apps 2
B TableLayout verhält sich nicht wie eine Tabelle Android & Cross-Platform Mobile Apps 3
E LayoutInflater funktioniert nicht Android & Cross-Platform Mobile Apps 2
J Sensor Orientierung -> GLRotation stimmt nicht Android & Cross-Platform Mobile Apps 12
K Android Temperaturconverter, R.id.element wird nicht gefunden Android & Cross-Platform Mobile Apps 20
K Android Alarm Manager (Wakelock? ) geht nicht Android & Cross-Platform Mobile Apps 4
A onDraw wird nicht aufgerufen Android & Cross-Platform Mobile Apps 14
A Kann nicht in TextView einer anderen Klasse schreiben - wieso? Android & Cross-Platform Mobile Apps 9
A Android setVisibility reagiert nicht Android & Cross-Platform Mobile Apps 2
A Android Dialog wird nicht sofort angezeigt Android & Cross-Platform Mobile Apps 12

Ähnliche Java Themen

Neue Themen


Oben