Hallo zusammen.
Ich habe ein Spiel für Android programiert und möchte das Save-Game anlegen.
Mein Problem ist folgendes.
Auf den Emulatoren in Android Studio Android-Versionen von 4.2 bis 7 und auf meinem Samsung Galaxy Tab 2 Android 4.2.2 funktioniert das Einwandfrei.
Aber auf meinem Android Galaxy S6 nicht.
Habe daraufhin mein altes Galaxy S5 aus der Schublade gekruschtelt und darauf funzt es auch nicht.
Es wird kein Directory erstellt und die Datei wird nicht angelegt.
Dies ist meine Manifest Datei.
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Factory">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="25"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="Burger Factory"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="Burger Factory"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
.....
<activity
android:name=".Bilanzen2Activity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" />
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
|
In der Quelltext Datei habe ich folgende Zeilen.
Zum Schreiben.
|
Quellcode
|
1
2
3
4
|
dirs=new File(Environment.getExternalStorageDirectory() + "/Burger Factory/");
dirs.mkdirs();
file = new FileOutputStream(Environment.getExternalStorageDirectory() + "/Burger Factory/Save");
DataOutputStream dos = new DataOutputStream(file);
|
und zum Lesen.
|
Quellcode
|
1
2
3
4
|
FileInputStream file = new FileInputStream(Environment.getExternalStorageDirectory() + "/Burger Factory/Save");
try {
DataInputStream dos = new DataInputStream(file);
|
Kann mir jemand da weiterhelfen.
Vielen Dank.