android-sdcard

How to get file name from file path in android

て烟熏妆下的殇ゞ 提交于 2019-11-27 01:00:41
问题 I want to get file name from sdcard file path. e.g. : /storage/sdcard0/DCIM/Camera/1414240995236.jpg I want get 1414240995236.jpg I have written the code to fetch the same but it is not working. Please help. Below is my code: @Override protected void onActivityResult( int requestCode, int resultCode, Intent data) { if ( requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { if ( resultCode == RESULT_OK) { /*********** Load Captured Image And Data Start ****************/ String imageId =

Stop saving photos using Android native camera

主宰稳场 提交于 2019-11-27 00:52:14
I am using native Android camera and save file to my application data folder (/mnt/sdcard/Android/data/com.company.app/files/Pictures/). At the same time anther copy of photo is saved to DCIM folder. This is my code: Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); String formattedImageName = getDateString() + ".jpg"; File image_file = new File(this.getExternalFilesDir(Environment.DIRECTORY_PICTURES), formattedImageName); Uri imageUri = Uri.fromFile(image_file); intent.putExtra(MediaStore.EXTRA_OUTPUT,imageUri); startActivityForResult(intent, REQUEST_FROM_CAMERA); How can I prevent

Android SD Card Write Permission using SAF (Storage Access Framework)

微笑、不失礼 提交于 2019-11-27 00:51:45
After a lot of findings about how to write(and rename) a file in SD Card (android 5 and above), I think the new SAF provided by android will be required to take permission from user to write SD card file. I have seen in this File Manger Application ES File Explorer that initially it takes read and write permission the following way as shown in pictures. After selecting sd card, the write permission is granted. So in the same way I tried to use SAF, but failed in renaming a file. My code: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

Android songs fetching from SD card

青春壹個敷衍的年華 提交于 2019-11-26 23:19:39
问题 I am fetching my songs from the SD card and putting him to the list view. I am using this method. but its taking some time and if path is different I didn't get that data. so , QUE Is there any helpfull script that display songs from all my sd card. If they are into directory/songs . public ArrayList<HashMap<String, String>> getPlayList(){ File home = new File(MEDIA_PATH); if (home.listFiles(new FileExtensionFilter()).length > 0) { for (File file : home.listFiles(new FileExtensionFilter())) {

Removable storage (external) sdcard path by manufacturers

空扰寡人 提交于 2019-11-26 22:38:46
问题 I've been Googling around but it is sooooo hard to find what manufacturers/models use which path for sdcard/external storage. I am NOT talking about the internal storage path which can be found by: Environment.getExternalStorageDirectory() I know that getExternalStorageDirectory() sometimes points to external sdcard on some devices. Here's what I've found some common path for external path (Not sure which manufacturer uses which path): /emmc /mnt/sdcard/external_sd /mnt/external_sd /sdcard/sd

Simple mediaplayer play mp3 from file path?

我是研究僧i 提交于 2019-11-26 22:38:32
I have a very simple mediaplayer that play background. It calls file from the apk, but I want it to play from any directory like as music or sdcard. Here are my codes: private MediaPlayer mpintro; . . mpintro = MediaPlayer.create(this, R.raw.intro); mpintro.setLooping(true); mpintro.start(); It works like this: mpintro = MediaPlayer.create(this, Uri.parse(Environment.getExternalStorageDirectory().getPath()+ "/Music/intro.mp3")); mpintro.setLooping(true); mpintro.start(); It did not work properly as string filepath... String filePath = Environment.getExternalStorageDirectory()+"/yourfolderNAme

Android - Taking photos and saving them with a custom name to a custom destination via Intent

 ̄綄美尐妖づ 提交于 2019-11-26 22:25:39
I have a program that opens the camera via Intent to take a photo. That much part works fine already. However, I want it to save to a certain folder with a certain file name (the file name is optional but it would really really help). So here's what I have so far. Here's the line of code that opens the camera: //TODO camera stuff. Intent openCam = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //The two lines of code below were commented out at first. //They were eventually added when I tried to save it with a custom name and destination fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); //

is there a maximum size to android internal storage allocated for an app?

爱⌒轻易说出口 提交于 2019-11-26 22:22:06
问题 I want to save a json file with all the application data (something similar to preference) but im not sure what is the limit size, because if the app cant use this file it will not function probably. is this information known beforehand and the OS reserve some space for your app or its based on the size available. Update: I dont really care about External storage since is not always available in the device and could be changed (SD card) and i could check for internal storage using this but

How to open SDCARD of android using phonegap

本秂侑毒 提交于 2019-11-26 22:11:17
问题 Hi all i was trying to upload a pdf file to my php server script i pdf file is there on android mobile it will be on sd card only so i want to open sd card of android device using phonegap via javascript. 回答1: U can easily do that its very easy window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccessUpload, fail); function onFileSystemSuccessUpload(fileSystem) { // get directory entry through root and access all the folders var directoryReader = fileSystem.root.createReader

Android KitKat 4.4 folder on sd card

心不动则不痛 提交于 2019-11-26 20:37:44
问题 We've just fallen foul of the new permissions that apply to writing files to sd cards (external storage) on Android 4.4 (EACCES Permission Denied) Prior to KitKat we set our writable folder like this: mfolder = Environment.getExternalStorageDirectory().getPath() + "/appfiles"; However after hours of searching I've come to the conclusion, rightly or wrongly that on 4.4 devices to enable writing of files this needs to be changed to: mfolder = Environment.getExternalStorageDirectory().getPath()