i have problem with writting to OTG USB.
-tablet Lenovo Yoga 8
-Android 4.4
-write to internal storage(/storage/sdcard0) and external microSD (/storage/sdcard1) working without problem
-path to USB -> /storage/usbotg
-ES File Manager writing to USB without problem
Thank you very much, and sorry my english.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xx.xxxxx.xxxx"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
...
MainActivity.java
File file = new File("/storage/usb0/report.pdf");
OutputStream os = new FileOutputStream(file);
document.writeTo(os);
document.close();
os.close();
Related
I am trying to log some actions to /sdcard. My AndroidManifest.xml specifies android:targetSdkVersion="22" and includes
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="<REDACTED-MYPACKAGENAME>"
android:versionCode="100"
android:versionName="1.00">
<uses-sdk android:targetSdkVersion="22"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
More...
Unfortunately, my writes to /sdcard/events.txt cause exception
java.io.FileNotFoundException: /sdcard/events.txt: open failed: EACCESS (Permission denied)
Notes:
Since the API level is <23, I believe run-time-permissions are not required.
If I manually enable "Storage" using "Settings"->"Apps->MyApp->"Permissions", it works just fine.
I am running on a Samsung S-9 running Android V10.
What am I missing?
I am creating an app in which I would like to read a file from the sd card and then write to another file using info from the other file. When attempting to read the file I get the following error: System.UnauthorizedAccessException: Access to the path 'sdcard/android/data/App1.App1/files/' is denied.
Read Function:
private string ReadFile(string fileName)
{
var path = "sdcard/android/data/App1.App1/files/";
var filePath = Path.Combine(path.ToString(), fileName);
string text = File.ReadAllText(path.ToString());
return text;
}
Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="App1.App1" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="16" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:label="Scout" android:icon="#drawable/Icon" android:theme="#style/CustomActionBarTheme"></application>
</manifest>
I have solved the issue and found that I was trying to read a folder instead of the file itself. When switching out the variable path with filePath int the read all text function the error went away.
Do not forget to add
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
into the manifest. This allows to read and write on SD card.
More details about uses-permission
It can also be a problem with your simulator and your sd card, read this topic
I am new to android development. I am creating Scandit barcode scanner application which is using android emulator's camera (webcam).
I have configured camera permissions related stuffs in AndroidManifest.xml file as below:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="AndroidDemo.AndroidDemo" android:installLocation="auto">
<uses-sdk android:minSdkVersion="10" />
<application android:label="AndroidDemo"></application>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.camera.autofocus" />
</manifest>
Now the logcat showing the following error:
07-21 13:21:03.026 E/EmulatedCamera_QemuClient( 63): queryStart: Query failed: Cannot start the camera
07-21 13:21:03.026 E/EmulatedCamera_QemuDevice( 63): startDevice: Unable to start device 'AndroidEmulatorVC0' for NV21[640x480] frames
Initially it was working fine.now i didnt change any code but it is not working. The camera functionality is randomly working.I am not sure how to troubleshoot this.
And my emulator config is given below(visual studio):
And related question is not answered
Thanks.
I'm developing an Android app and I am not able to install it in the SD Card. This is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.developfrank.application"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="preferExternal">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
I use as minimum version required Froyo 2.2 so I don't have any errors about the option installLocation, but at the moment of installing the app, my mobile installs it in the internal memory.
I also have these two permissions, I put it just in case it can give some clues:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
I tried many things and I am a bit lost. Thank you very much for your help
Frank.
I'm trying to create folder on the SDCard on Android 2.3 device:
final File downloadFolder = new File(FILES_PATH);
if (!downloadFolder.exists()) {
Log.i(TAG, "Creating tmp directory: " + downloadFolder.mkdirs());
}
And mkdirs() returns false. FILES_PATH is the same that getExternalStorage() returns - /mnt/sdcard/.tmp/
SD card is writable from the cli with root.
Permission:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.venturezlab.tvupdater"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Why?
Try mkdir() instead of mkdirs()
Try this
final File downloadFolder = new File(Environment.getExternalStorageDirectory()+"/.tmp");