android-sdcard

How to get file name from file path in android

狂风中的少年 提交于 2019-11-28 05:41:34
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 = convertImageUriToFile( imageUri,CameraActivity); // Create and excecute AsyncTask to load capture image new

storing android application data on SD Card

扶醉桌前 提交于 2019-11-28 03:41:29
Is there a way to store android application data on the SD card instead of in the internal memory? I know how to transfer the application sqlite database from the internal memory to the SDCard, but what if the internal memory gets full in the first place? How does everyone handle this? haseman Warning: This answer is out-dated. You should use Environment.getExternalStorageDirectory() to get the root path of the SD card as mentioned in the answers below. Old Answer so the comments on this make sense: Adding /sdcard/ to the root your path should direct your Android application to use the SD card

How to open SDCARD of android using phonegap

孤街醉人 提交于 2019-11-28 02:22:47
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. 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(); // Get a list of all the entries in the directory directoryReader.readEntries(successReader,fail); }

Android: How to access a file in the SD Card

冷暖自知 提交于 2019-11-28 01:52:53
问题 I'm trying to access the image on the SD card using below code but I"m getting File not found exception. Can someone tell me a correct way to acess the file??? new File("/mnt/sdcard/splah2.jpg") 回答1: Try like this: String SD_CARD_PATH = Environment.getExternalStorageDirectory().toString(); new File(SD_CARD_PATH + "/" + "splah2.jpg"); 回答2: Try running: new File(Environment.getExternalStorageDirectory() + "/splah2.jpg") 回答3: try this, File f=new File("/sdcard/splah2.jpg"); 回答4: The code below

Copy folders in /data/data to sdcard & vice-versa

最后都变了- 提交于 2019-11-28 01:22:01
问题 I have a problem when I try to copy folders inside /data/data to SDcard. I have my phone rooted. I request Superuser permissions in my app with: Runtime.getRuntime().exec("su"); I'm using FileUtils from Apache to copy files/folders. What I discovered is if I manually change the folders permissions to READ I can copy it from /data/data to SDcard. Is there any way to recursively change the RW permissions of all folders inside /data/data to read and write folders? I've tried chmod but It doesn't

Cannot Write to sdcard in Android emulator

点点圈 提交于 2019-11-27 23:43:17
I have added this line in the AndroidManifest.xml: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> However, when I run code to write to the sdcard , I get this Error: 02-19 13:24:46.760: E/CameraTest(598): /mnt/sdcard/image.jpg: open failed: EACCES (Permission denied) How do I solve this problem? EDIT: I am using the Android Emulator with SDCard added. EDIT-2: I know what the problem is now: I have called the function Environment.getExternalStorageState() and I get "removed". Anyone knows how to fix this and make the state MEDIA_MOUNTED Thank You! Ok So I have

Android songs fetching from SD card

喜夏-厌秋 提交于 2019-11-27 23:22:32
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())) { HashMap<String, String> song = new HashMap<String, String>(); song.put("songTitle", file.getName()

How to create a video thumbnail from a video file path in Android?

丶灬走出姿态 提交于 2019-11-27 21:38:47
问题 I want to create a thumbnail of a video from the SD card path. How can I do that? 回答1: You can use ThumbnailUtils class to get Video thumbnail of Video file. createVideoThumbnail() is method which return Bitmap (thumbnail) of video from video file path. From Android Docs: public static Bitmap createVideoThumbnail (String filePath, int kind) Create a video thumbnail for a video. May return null if the video is corrupt or the format is not supported. You can create VideoThumbnail from sdcard

Android KitKat 4.4 folder on sd card

妖精的绣舞 提交于 2019-11-27 21:20:12
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() + "/Android/data/com.xyz.abc/appfiles"; So mfolder would be something like: /mnt/sdcard/Android/data

Android SD card writing, Permission Denied

久未见 提交于 2019-11-27 21:19:53
I am trying to write a file to SDCard with below Code (permission android.permission.WRITE_EXTERNAL_STORAGE already set in manifest.xml). Upon execution of nmea_file.createNewFile(); it throws exception with Permission Denied . Any guesses why would this be happening? if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { Log.d(TAG, "Sdcard was not mounted !!" ); } else { File nmea_file; File root = Environment.getExternalStorageDirectory(); FileWriter nmea_writer = null; try { nmea_file = new File(root,"NMEA.txt"); if(!nmea_file.exists()) { Log.w(TAG, "File Doesn't