android-sdcard

Android get images from sdcard

允我心安 提交于 2019-12-21 05:35:16
问题 I am using a code which is listing all the images from my device...and I'm trying to figure it out how to get images only from a specific folder, not all the images. Here is the code I'm using : ArrayList<Bitmap> images = new ArrayList<Bitmap>(); String[] projection = {MediaStore.Images.Thumbnails.DATA}; Uri uri = Uri.parse("content://media/external/images/media"); cursor = managedQuery( uri, projection, null, null, null); //cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,

Get .mp3 format files from android device

混江龙づ霸主 提交于 2019-12-21 05:29:09
问题 I'm developing a music player. I want to get all .mp3 format files from android device. But this code is not getting any files. My .mp3 files are in 'sdcard/music' folder. If i change the MEDIA_PATH = new String("sdcard/music"); like this it's getting files only from that music folder. But i need to get all .mp3 files from each and every folder in my external/internal memorycard. Please help me. this is my code. final String MEDIA_PATH = new String(Environment.getExternalStorageDirectory());

Android 2.2 - How do I detect if I am installed on the SDCard or not?

六月ゝ 毕业季﹏ 提交于 2019-12-21 04:05:05
问题 I am writing an android app that stores a lot of media files. They are not the type (and are far too many) to clutter up the users notification or other media directories, but they also must be user-updatable, so I can't put them in the resources. I can use getExternalFilesDir to get a path on the sdcard, but I only want to do that if the app itself is installed on the sdcard. If the app is installed internally, I want to put the media in the internal memory. So how can I determine if my app

ExoPlayer - play local mp4 file in SD card

夙愿已清 提交于 2019-12-20 10:35:04
问题 I am using the Exoplayer Demo app and want to preload a MP4 video from SD card. I have tried out the implementation from this post, but it does not work. There is no such class called DemoUtil.java in my exoplayer Demo. Instead used: public static final Sample[] LOCAL_VIDEOS = new Sample[] { new Sample("Some User friendly name of video 1", "/mnt/sdcard/video1.mp4", Util.TYPE_OTHER), }; I also could not use the their snippet of code mentioned for SampleChooserActivity.java. (Kept giving me

Bug when listing files with Android Storage Access framework on Lollipop

安稳与你 提交于 2019-12-20 10:24:12
问题 Background I have a few apps that make heavy use of SD card for file syncing. The broken external SD card access on Kitkat is still a big problem, but I am trying to resolve this with the new API available on Lollipop for the users which have this. I successfully request and persist permission to SD card and I can list files in the root Uri returned from the grant permission activity. See more info on how this is done here: how-to-use-the-new-sd-card-access-api-presented-for-lollipop The user

How can i add sdcard images to coverflow?

匆匆过客 提交于 2019-12-20 06:15:14
问题 Here is my coverflow with drawables :( This is my Image Adapter Code /** The Constant IMAGE_RESOURCE_IDS. */ private static final List<Integer> IMAGE_RESOURCE_IDS = new ArrayList<Integer>(DEFAULT_LIST_SIZE); /** The Constant DEFAULT_RESOURCE_LIST. */ private static final int[] DEFAULT_RESOURCE_LIST = { R.drawable.promo_blue_bg_medium, R.drawable.promo_green_bg_medium, R.drawable.flow, R.drawable.promo_yellow_bg_medium, R.drawable.promo_black_bg_medium , }; /** The bitmap map. */ private final

Using webView's loadDataWithBaseURL not loading images from sdcard

淺唱寂寞╮ 提交于 2019-12-20 04:16:10
问题 I would like to set some html content in my webview with some pictures. I've read on the internet i must use loadDataWithBaseUrl to do such a thing because i need to link the folder of images (basUrl) in order. My html content nicely loads, i can even ran the javascripts perfectly, but for some reason my images cannot be loaded. Somewhere i've read there are some security reasons and thats why i cant load images from sd card to webview and some says it can be easily done via

android get all external storage path for all devices

前提是你 提交于 2019-12-19 04:21:33
问题 getExternalStorageDirectory() return SD card path on my phone. ( Huawei Y320 - android 4.2.2 ). now, how to get path Phone Storage path for all devices and all API? loot at bottom screenshot. 回答1: I'm using this method: public static final String SD_CARD = "sdCard"; public static final String EXTERNAL_SD_CARD = "externalSdCard"; private static final String ENV_SECONDARY_STORAGE = "SECONDARY_STORAGE"; public static Map<String, File> getAllStorageLocations() { Map<String, File> storageLocations

How to get sdcard(Secondary) storage path in android?

别说谁变了你拦得住时间么 提交于 2019-12-19 04:09:45
问题 I'm developing a File Manager app. I want show to the user the internal storage and the sdcard storage if it exists. For internal storage I use Environment.getExternalStorageDirectory().getPath() . How can I get the SD storage? 回答1: not sure this solution fits a File Manager but after many years trying to get the right code, this is my most recent one: /** * Returns all available SD-Cards in the system (include emulated) * * Warning: Hack! Based on Android source code of version 4.3 (API 18)

Android: remove an image from sd card

流过昼夜 提交于 2019-12-18 15:12:06
问题 I need to remove an image from sd card chosen by user. In my Activity, after an user select an image from gallery, i execute this code: public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { if (requestCode == SELECT_PICTURE) { Utils.imgUri = data.getData(); Utils.imgPath = getPath(Utils.imgUri); File file = new File(Utils.imgPath); boolean deleted = file.delete(); } } } where getPath method is: public String getPath(Uri uri) { String[]