android-sdcard

how to emulate a real external sd (update: removable storage) card in Android Emulator

久未见 提交于 2019-12-07 09:36:49
问题 I try to emulate a external sdcard as it would be in a real device. In a real device the external sdcard is not writeable except you use the new "Storage Access Framework" (API 21 & 22) When I add an sdcard either with a file or Size ... I always get a writeable sdcard, which is not true with a real device (I guess). I could create the Folder "CreateFolder" with just ( I know, I should not use the direct access, but this is only for a test to see if I have write access): String spathWriteTest

Android read/write permission of a folder

风流意气都作罢 提交于 2019-12-07 05:13:27
问题 I am doing a new android app. I want to create a folder in "Android" folder which is available in sdcard. Before that I want to check whether the folder has read/write permission. How can I get that? can anyone help me to do this. 回答1: You do it the old-school java way. Create a file object and call canWrite() and canRead() . File f = new File("path/to/dir/or/file"); if(f.canWrite()) { // hell yeah :) } 回答2: To create a folder in Android folder the best way is: File path = getExternalFilesDir

Find SD card volume label on Android

断了今生、忘了曾经 提交于 2019-12-06 20:18:58
问题 Is it possible to find out volume label of SD card inserted into Android device? I understand that Android is designed to have just one "external storage" (as returned by Environment.getExternalStorageDirectory() ), but there are quite a few devices in the wild that have internal flash as "external storage" and an SD card mounted under that or even wilder combinations (see this other question). It is possible to enumerate these additional devices by reading /proc/mounts , but we need

How to delete all the files from sd card in android? [duplicate]

眉间皱痕 提交于 2019-12-06 16:51:04
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to delete entire contents of sdcard programmatically in Android 2.2 I want to clear all the files from android device programmatically . Can anyone suggest me the way or code, Hence I can perform this operation please... Thanks in advance. 回答1: public static boolean deleteDirectory(File path) { // TODO Auto-generated method stub if( path.exists() ) { File[] files = path.listFiles(); for(int i=0; i<files

How to display images from SD card in a GalleryView

佐手、 提交于 2019-12-06 14:48:46
问题 I am trying to display all the images stored in SD card in a Gallery View. I have tried using the content provider (android.provider.MediaStore.images.Media class), but seem to be getting stuck at a point. Not sure if this is the way to go about it. Here is my code so far: String[] colsNeeded = new String[]{Media._ID, Media.TITLE}; Uri mMedia = Media.EXTERNAL_CONTENT_URI; //Create a cursor using the URI & column names needd Cursor c = managedQuery(mMedia, colsNeeded, null, null, Media.DATE

How to Getting Images from Sdcard's folder's Subfolder?

走远了吗. 提交于 2019-12-06 14:13:03
问题 Following code is used to get images from particular folder but how to get sub folder's images of sdcard's folder. Cursor actualimagecursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj, MediaStore.Images.Media.DATA + " like ? ", new String[] { "%unzipped%" }, null); Sorry for bad English communication. 回答1: Try with the following code public void searchImageFromSpecificDirectory() { String path = null; String uri = MediaStore.Images.Media.DATA; // if

Writing to SD Card always failing

偶尔善良 提交于 2019-12-06 13:54:35
问题 I am trying to move files from any location (including internal device storage) to SD Card, For that I Have <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> in my manifest, and checked that it did work by checking if premissions are granted using : Contex.checkCallingOrSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") and Contex.checkCallingOrSelfPermission("android.permission

Store video files on SD card in Android 5

折月煮酒 提交于 2019-12-06 12:24:58
问题 I'm recording video with the aid of android.media.MediaRecorder class, which accepts path string for output file (MediaRecorder.setOutputFile(String)), though there is a version of the method which accepts FileDescriptor . I need to store huge video files, so I want to use SD card. In order to get path to relevant directory I use Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) . It turns out that resulting path is for the “emulated” storage ( /sdcard/… ) instead of

How does the multi-user feature work in terms of paths on Android?

为君一笑 提交于 2019-12-06 10:42:59
问题 background Starting with version 4.2 , Android supports multi-user (link here and here). Each user has its apps and their private data is visible just for the user. The question How does the encapsulation of the data per user work in terms of paths and accessing files? I mean, what will be the paths per each user for: the private, internal storage. the emulated external storage (built in external storage) the "real" external storage (sd cards) ? I guess users can see the data stored on the sd

Getting the path to SD card

为君一笑 提交于 2019-12-06 09:40:34
Please read the whole post before down-voting and/or marking it as a duplicate! I'm working on an app that reads files from within a specific folder on the user's phone - either from the SD card (if there's one) or from the built in storage. Yes, the "READ_EXTERNAL_STORAGE" is mentioned in the manifest and I'm also handling the permission popup for API>23. I used to simply use File folder = new File(Environment.getExternalStorageDirectory(), "myfolder"); to get the path of the folder that is stored in the built in storage (32gb for an S7) but now I want to get the path to the SD card.