android-sdcard

error opening trace file: No such file or directory (2)

回眸只為那壹抹淺笑 提交于 2019-11-26 01:59:16
I am getting the above error: error opening trace file: No such file or directory (2) when I run my android application on the emulator. Can someone tell me what could be the possible reason for this? I am using android-sdk-20 and below lines are added to AndroidManifest.xml <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" /> I have also added the line: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> since I thought that there may be some issue with writing to the sd card. It happens because you have not installed the minSdkVersion or

How can I get the external SD card path for Android 4.0+?

ε祈祈猫儿з 提交于 2019-11-26 01:21:46
问题 Samsung Galaxy S3 has an external SD card slot, which is mounted to /mnt/extSdCard . How can I get this path by something like Environment.getExternalStorageDirectory() ? This will return mnt/sdcard , and I can\'t find the API for the external SD card. (Or removable USB storage on some tablets.) 回答1: I have a variation on a solution I found here public static HashSet<String> getExternalMounts() { final HashSet<String> out = new HashSet<String>(); String reg = "(?i).*vold.*(vfat|ntfs|exfat

Solution to INSTALL_FAILED_INSUFFICIENT_STORAGE error on Android [closed]

半世苍凉 提交于 2019-11-26 01:03:49
问题 The INSTALL_FAILED_INSUFFICIENT_STORAGE error is the bane of every Android developer\'s life. It happens regardless of app size, or how much storage is available. Rebooting the target device fixes the problem briefly, but it soon comes back. There are hundreds (if not thousands) of message board posts from people asking why the problem occurs, but the folks at Google are frustratingly silent on the issue. There is a simple workaround. If your test device is running Android 2.2 or later then

How to delete a file from SD card?

…衆ロ難τιáo~ 提交于 2019-11-26 00:25:21
问题 I am creating a file to send as an attachment to an email. Now I want to delete the image after sending the email. Is there a way to delete the file? I have tried myFile.delete(); but it didn\'t delete the file. I\'m using this code for Android, so the programming language is Java using the usual Android ways to access the SD card. I am deleting the file in the onActivityResult method, when an Intent is returned to the screen after sending an email. 回答1: File file = new File(selectedFilePath)

How to use the new SD card access API presented for Android 5.0 (Lollipop)?

不打扰是莪最后的温柔 提交于 2019-11-25 23:59:45
问题 Background On Android 4.4 (KitKat), Google has made access to the SD card quite restricted. As of Android Lollipop (5.0), developers can use a new API that asks the user to confirm to allow access to specific folders, as written on the this Google-Groups post . The problem The post directs you to visit two websites: https://android.googlesource.com/platform/development/+/android-5.0.0_r2/samples/Vault/src/com/example/android/vault/VaultProvider.java#258 This looks like an inner example

How can I read a text file from the SD card in Android?

被刻印的时光 ゝ 提交于 2019-11-25 23:44:21
问题 I am new to Android development. I need to read a text file from the SD card and display that text file. Is there any way to view a text file directly in Android or else how can I read and display the contents of a text file? 回答1: In your layout you'll need something to display the text. A TextView is the obvious choice. So you'll have something like this: <TextView android:id="@+id/text_view" android:layout_width="fill_parent" android:layout_height="fill_parent"/> And your code will look

Android get free size of internal/external memory

孤街醉人 提交于 2019-11-25 23:43:44
问题 I want to get the size of free memory on internal/external storage of my device programmatically. I\'m using this piece of code : StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); long bytesAvailable = (long)stat.getBlockSize() *(long)stat.getBlockCount(); long megAvailable = bytesAvailable / 1048576; Log.e(\"\",\"Available MB : \"+megAvailable); File path = Environment.getDataDirectory(); StatFs stat2 = new StatFs(path.getPath()); long blockSize = stat2

Android write to sd card folder

被刻印的时光 ゝ 提交于 2019-11-25 23:14:04
问题 I am using the following code to download a file from my server then write it to the root directory of the sd card, it all works fine: package com.downloader; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import android.os.Environment; import android.util.Log; public class Downloader { public void DownloadFile(String fileURL, String fileName) { try { File root = Environment.getExternalStorageDirectory(

Android 6.0 Marshmallow. Cannot write to SD Card

旧时模样 提交于 2019-11-25 21:37:01
I have an app that uses external storage to store photographs. As required, in its manifest, the following permissions are requested <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> and it uses the following to retrieve the required directory File sdDir = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd", Locale.US); String date = dateFormat.format(new Date()); storageDir = new File(sdDir, getResources().getString( R