android intent for sdcard ready

Lookup ACTION_MEDIA_MOUNTED broadcast action on the Intent public static final String ACTION_MEDIA_MOUNTED Since: API Level 1 Broadcast Action: External media is present and mounted at its mount point. The path to the mount point for the removed media is contained in the Intent.mData field. The Intent contains an extra with name “read-only” and Boolean value … Read more

Save image to sdcard from drawable resource on Android

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); The path to SD Card can be … Read more

Getting all the total and available space on Android

Here is how you get internal storage sizes: StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long blockSize = statFs.getBlockSize(); long totalSize = statFs.getBlockCount()*blockSize; long availableSize = statFs.getAvailableBlocks()*blockSize; long freeSize = statFs.getFreeBlocks()*blockSize; Here is how you get external storage sizes (SD card size): StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath()); long blockSize = statFs.getBlockSize(); long totalSize = statFs.getBlockCount()*blockSize; long availableSize … Read more

How to save file from website to sdcard

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(dir.exists()==false) { dir.mkdirs(); } URL url = new URL(DownloadUrl); //you can write here any link File file = … Read more

Unzip a zipped file on sd card in Android application

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(“”); } public void unzip() { try { FileInputStream fin = new FileInputStream(_zipFile); ZipInputStream zin … Read more

Scan Android SD card for new files

I’ve tried plenty of different methods to trigger the MediaScanner, and these are my results. SendBroadcast The most simple and naive solution. It consists in executing the following instruction from your code: sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse(“file://”+ Environment.getExternalStorageDirectory()))); However, this no longer works in KitKat devices, due to a lack of required permissions. MediaScannerWrapper As posted here … Read more