Új hozzászólás Aktív témák
-
SektorFlop
aktív tag
Sziasztok!
Már jó rég jártam itt, viszont most nagyon csúnyán elakadtam egy egyszerű dologgal. Van egy egyszerű kódom, ami lementene egy fájlt belső van külső tárhely /Android/data/... mappájába. 10 telefonból 9-en működik. A kivétel egy Huawei Y6 (Android 5.1.1, EMUI 3.1) Valakinek volt hasonló problémája? Vagy esetleg megoldást tud rá valaki?
A leegyszerűsített program rész:
public void createFile(TextView textView){
String filepath ="/storage/sdcard1/Android/data/com.example.app/route.txt";
FileOutputStream fos = null;
try {
fos = new FileOutputStream(filepath);
byte[] buffer = "Ez lesz írva a fájlba".getBytes();
fos.write(buffer, 0, buffer.length);
fos.close();
textView.setText("Saved");
} catch (FileNotFoundException e) {
e.printStackTrace();
textView.setText(e.toString());
} catch (IOException e) {
e.printStackTrace();
textView.setText(e.toString());
}finally{
if(fos != null)
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
textView.setText(e.toString());
}
}
}Manifestben következő permissionok:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />11-08 09:18:52.442 6957-6957/com.mobilengine.filesavetest W/System.err: java.io.FileNotFoundException: /storage/sdcard1/Android/data/com.example.app/route.txt: open failed: EACCES (Permission denied)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at libcore.io.IoBridge.open(IoBridge.java:494)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:127)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:116)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at com.mobilengine.filesavetest.MainActivity.createFile(MainActivity.java:36)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at com.mobilengine.filesavetest.MainActivity.onCreate(MainActivity.java:27)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at android.app.Activity.performCreate(Activity.java:6102)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at android.app.ActivityThread.access$1200(ActivityThread.java:165)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at android.os.Looper.loop(Looper.java:135)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5593)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at java.lang.reflect.Method.invoke(Native Method)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at libcore.io.Posix.open(Native Method)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: at libcore.io.IoBridge.open(IoBridge.java:480)
11-08 09:18:52.452 6957-6957/com.mobilengine.filesavetest W/System.err: ... 18 more
Új hozzászólás Aktív témák
- Szép Apple iPhone 13 Pro Max 256GB / AKKU 100% / 12 hónap jótállás
- BESZÁMÍTÁS! Lenovo Legion 5 16RX9 Gamer notebook - i7 14650HX 32GB DDR5 1TB SSD RTX 4070 8GB
- GYÖNYÖRŰ iPhone 14 128GB Midnight-1 ÉV GARANCIA - Kártyafüggetlen, MS4496
- Dell , Lenovo, Microsoft Core i5 - i7 - 6-7-8-10-11-12. gen. üzleti kategóriás notebookok számlával
- Azonnali készpénzes AMD CPU AMD VGA számítógép felvásárlás személyesen / postával korrekt áron
Állásajánlatok
Cég: Central PC számítógép és laptop szerviz - Pécs
Város: Pécs
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest

