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

It happens because you have not installed the minSdkVersion or targetSdkVersion in you’re computer. I’ve tested it right now. For example, if you have those lines in your Manifest.xml: <uses-sdk android:minSdkVersion=”8″ android:targetSdkVersion=”17″ /> And you have installed only the API17 in your computer, it will report you an error. If you want to test it, … Read more

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

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 like this: //Find the directory for the SD Card using the API //*Don’t* hardcode “/sdcard” File sdcard = Environment.getExternalStorageDirectory(); //Get the text file File … Read more

Universal way to write to external SD card on Android

Summary You can grant read/write access to external SD card on the different api levels (API23+ at run time). Since KitKat, permissions are not necessary if you use app-specific directories, required otherwise. Universal way: The history says that there is no universal way to write to external SD card but continues… This fact is demonstrated … Read more

Android: How to open a specific folder via Intent and show its content in a file browser?

This should help you: Uri selectedUri = Uri.parse(Environment.getExternalStorageDirectory() + “/myFolder/”); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(selectedUri, “resource/folder”); if (intent.resolveActivityInfo(getPackageManager(), 0) != null) { startActivity(intent); } else { // if you reach this place, it means there is no any file // explorer app installed on your device } Please, be sure that you have any … Read more

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

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|fat32|ext3|ext4).*rw.*”; String s = “”; try { final Process process = new ProcessBuilder().command(“mount”) .redirectErrorStream(true).start(); process.waitFor(); final InputStream is = process.getInputStream(); final byte[] buffer = new byte[1024]; while (is.read(buffer) != -1) { … Read more

Reading an image file into bitmap from sdcard, why am I getting a NullPointerException?

The MediaStore API is probably throwing away the alpha channel (i.e. decoding to RGB565). If you have a file path, just use BitmapFactory directly, but tell it to use a format that preserves alpha: BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeFile(photoPath, options); selected_photo.setImageBitmap(bitmap); or http://mihaifonoage.blogspot.com/2009/09/displaying-images-from-sd-card-in.html

Android get free size of internal/external memory

Below is the code for your purpose : public static boolean externalMemoryAvailable() { return android.os.Environment.getExternalStorageState().equals( android.os.Environment.MEDIA_MOUNTED); } public static String getAvailableInternalMemorySize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSizeLong(); long availableBlocks = stat.getAvailableBlocksLong(); return formatSize(availableBlocks * blockSize); } public static String getTotalInternalMemorySize() { File path = Environment.getDataDirectory(); StatFs stat … Read more

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

Lots of good questions, let’s dig in. 🙂 How do you use it? Here’s a great tutorial for interacting with the Storage Access Framework in KitKat: https://developer.android.com/guide/topics/providers/document-provider.html#client Interacting with the new APIs in Lollipop is very similar. To prompt the user to pick a directory tree, you can launch an intent like this: Intent intent … Read more

File not found.