sd-card

How can I get the size of a folder on SD card in Android?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 00:52:36
Is it possible to easily get the size of a folder on the SD card? I use a folder for caching of images, and would like to present the total size of all cached images. Is there a way to this other than iterating over each file? They all reside inside the same folder? Moss Just go through all files and sum the length of them: /** * Return the size of a directory in bytes */ private static long dirSize(File dir) { if (dir.exists()) { long result = 0; File[] fileList = dir.listFiles(); for(int i = 0; i < fileList.length; i++) { // Recursive call if it's a directory if(fileList[i].isDirectory()) {

How to get an External storage sd card size (With Mounted SD card)?

回眸只為那壹抹淺笑 提交于 2019-11-26 22:52:39
问题 Link :I worked on based on this Link I added this line to find the size (both Internal and External) size, return availableExternalMemorySize/(1024*1024); I tested in my Tablet. I am getting both Internal and External SD card size as, In Internal Storage: Total Memory --1007 Available Memory --683 In External Storage: Total Memory -- 1763 Available Memory -- 1554 But in Tablet, I saw settings. An External Storage size has 8GB. But it is showing me 1.7 GB around when I tested via

Removable storage (external) sdcard path by manufacturers

空扰寡人 提交于 2019-11-26 22:38:46
问题 I've been Googling around but it is sooooo hard to find what manufacturers/models use which path for sdcard/external storage. I am NOT talking about the internal storage path which can be found by: Environment.getExternalStorageDirectory() I know that getExternalStorageDirectory() sometimes points to external sdcard on some devices. Here's what I've found some common path for external path (Not sure which manufacturer uses which path): /emmc /mnt/sdcard/external_sd /mnt/external_sd /sdcard/sd

How to save file from website to sdcard

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 21:47:34
Does anyone know how to save a file from a webserver(local host) to the sdcard through wifi? I am doing xml parsing to my application and for that I have to download an xml file from localhost to the sdcard and then tag the parsing. I am stuck with downloading an xml file to the sd card. Please guide me on how to do this.. You can use this method to download a file from the internet to your SD card: public void DownloadFromUrl(String DownloadUrl, String fileName) { try { File root = android.os.Environment.getExternalStorageDirectory(); File dir = new File (root.getAbsolutePath() + "/xmls"); if

EACCESS Permission denied in Android

蹲街弑〆低调 提交于 2019-11-26 21:38:32
问题 While writing file in External SD card I am getting an error EACCESS permission denied. I have set the permission <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> But the when I read the file I am successfully able to read it but not able to write the file. The code that I am using for writing the file in SD card is: String path="mnt/extsd/Test"; try{ File myFile = new File(path, "Hello.txt"); //device.txt myFile.createNewFile(); FileOutputStream fOut = new

Unzip a zipped file on sd card in Android application

我与影子孤独终老i 提交于 2019-11-26 20:56:11
I have a zipped password protected a video file saved on sd card on android emulator. Now i want to unzip that video file on sd card through code. How can i achieve that? Any help or code? Thanks in advance import android.util.Log; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; /** * * @author jon */ public class Decompress { private String _zipFile; private String _location; public Decompress(String zipFile, String location) { _zipFile = zipFile; _location = location; _dirChecker(""); }

Decoding bitmaps in Android with the right size

拥有回忆 提交于 2019-11-26 18:28:45
I decode bitmaps from the SD card using BitmapFactory.decodeFile . Sometimes the bitmaps are bigger than what the application needs or that the heap allows, so I use BitmapFactory.Options.inSampleSize to request a subsampled (smaller) bitmap. The problem is that the platform does not enforce the exact value of inSampleSize, and I sometimes end up with a bitmap either too small, or still too big for the available memory. From http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inSampleSize : Note: the decoder will try to fulfill this request, but the resulting

SQLiteOpenHelper - creating database on SD card

余生长醉 提交于 2019-11-26 17:49:48
问题 in my test android app I intend to create and access database file, which will be located on SD card. I am using main activity with help of a class, which extends SQLiteOpenHelper. I want to use it the same way as before, but I have to somehow change the database PATH. Do you know, how to achieve it? thx My current code of a class which extends SQLiteOpenHelper: public class DatabaseDefinition extends SQLiteOpenHelper{ private static final String DATABASE_NAME="test.db"; private static final

Save image to sdcard from drawable resource on Android

ぃ、小莉子 提交于 2019-11-26 17:43:31
I'm wondering how to save an image to user's sdcard through a button click. Could some one show me how to do it. The Image is in .png format and it is stored in the drawable directory. I want to program a button to save that image to the user's sdcard. Imran Rana The process of saving a file (which is image in your case) is described here: save-file-to-sd-card Saving image to sdcard from drawble resource: Say you have an image namely ic_launcher in your drawable. Then get a bitmap object from this image like: Bitmap bm = BitmapFactory.decodeResource( getResources(), R.drawable.ic_launcher);

Android Open External Storage directory(sdcard) for storing file

随声附和 提交于 2019-11-26 17:19:54
I want to open external storage directory path for saving file programatically.I tried but not getting sdcard path. How can i do this?is there any solution for this?? private File path = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + ""); or private File path = new File(Environment.getExternalStorageDirectory() + ""); I tried getting path from above both methods but both are pointing internal memory. When we open storage memory if sdcard is peresent it will shows like below- device storage & sd memory card. I want to get sd memory path through coding.