Android Open External Storage directory(sdcard) for storing file

I had been having the exact same problem! To get the internal SD card you can use String extStore = System.getenv(“EXTERNAL_STORAGE”); File f_exts = new File(extStore); To get the external SD card you can use String secStore = System.getenv(“SECONDARY_STORAGE”); File f_secs = new File(secStore); On running the code extStore = “/storage/emulated/legacy” secStore = “/storage/extSdCarcd” works … Read more

Android – Application (apk) Maximum size

Today i came across one point where it is clearly defined that we can upload maximum 50MB sized APK onto the market. So indirectly, we can install an application from a market having maximum 50MB size. Here is a link: http://www.google.com/support/androidmarket/developer/bin/answer.py?hl=en&answer=113469 , here just check the below sentence. APK file size: Maximum supported size is … Read more

How do I backup a database file to the SD card on Android?

This code works for me! try { File sd = Environment.getExternalStorageDirectory(); File data = Environment.getDataDirectory(); if (sd.canWrite()) { String currentDBPath = “//data//{package name}//databases//{database name}”; String backupDBPath = “{database name}”; File currentDB = new File(data, currentDBPath); File backupDB = new File(sd, backupDBPath); if (currentDB.exists()) { FileChannel src = new FileInputStream(currentDB).getChannel(); FileChannel dst = new FileOutputStream(backupDB).getChannel(); dst.transferFrom(src, … Read more

Android how to use Environment.getExternalStorageDirectory()

Environment.getExternalStorageDirectory().getAbsolutePath() Gives you the full path the SDCard. You can then do normal File I/O operations using standard Java. Here’s a simple example for writing a file: String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath(); String fileName = “myFile.txt”; // Not sure if the / is on the path or not File f = new File(baseDir + File.separator + … Read more

Find location of a removable SD card

Environment.getExternalStorageState() returns path to internal SD mount point like “/mnt/sdcard” No, Environment.getExternalStorageDirectory() refers to whatever the device manufacturer considered to be “external storage”. On some devices, this is removable media, like an SD card. On some devices, this is a portion of on-device flash. Here, “external storage” means “the stuff accessible via USB Mass Storage … Read more