sd-card

android: how can get full path of a file stored in a folder in sdcard?

為{幸葍}努か 提交于 2019-11-29 23:53:03
问题 I am working in android. i want to get the full path of a file selected by user. my files are stored in sdcard. but may be in a folder in sd card. I have some folders in my sdcard. I want to get the full path of a file on which i click. Suppose I have an image peacock.png in folder image/birds. So the path is mnt/sdcard/image/birds/peacock.png Please suggest me how can i get the full path of a file. If you need my code which i am using for help then tell me i will send it here. Thank you in

Not getting the SD Card related intents to my broadcast receiver

倖福魔咒の 提交于 2019-11-29 19:55:01
问题 I am trying to register a receiver for the removal of the sdcard, but my receiver is not getting called on removal of the sd card pasting my code here. I am registering the receiver in the oncreate() and unregistering in the ondestroy function. Please let me know if i am doing any mistake. void registerSDCardStateChangeListener() { final String MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; final String MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED"; final String MEDIA_BAD

saving gif file from drawable into phone sd? and remove it from sd after usage

喜夏-厌秋 提交于 2019-11-29 17:58:18
I have been searching on how to save file from Drawable into sd card OR phone's internal storage. All examples such as this one showed only for PNG type, I want to get GIF file from my drawable and save it into phone sd, and later remove it from sd after usage. Anybody please help with the code? I appreciate it! As far as i know there isn't such a native function on Android (maybe related to patent issues). You may try this library for your purpose. Usually its meant to create animated GIF but a file with just one picture (frame) should also work. So a complete example could be like this

How can I use an SD card for logging 16-bit data at 48 ksamples/s?

感情迁移 提交于 2019-11-29 17:38:36
问题 Background My board incorporates an STM32 microcontroller with an SD/MMC card on SPI and samples analogue data at 48 ksamples/s. I am using the Keil Real-time Library RTX kernel, and ELM FatFs. I have a high priority task that captures analogue data via DMA in blocks of 40 samples (40 x 16 bit); the data is passed via a queue of length 128 (which constitutes about 107 ms of sample buffering) to a second low priority task that collates sample blocks into a 2560 byte buffer (this being a

android: how to listen to “sd card removed unexpectedly”

你离开我真会死。 提交于 2019-11-29 14:03:28
I have a program that uses content from sd-card. I want to listen to different states like sd-card mounted or sd-card removed unexpectedly. How can I do so. An example would be of a great help. Thanks to all PravinCG You need to listen for ACTION_MEDIA_REMOVED and ACTION_MEDIA_MOUNTED . Create a receiver and listen for this action. EDIT: In your manifest file add this <receiver android:name=".MyReceiver" > <intent-filter> <action android:name="android.intent.action.MEDIA_REMOVED" /> <action android:name="android.intent.action.MEDIA_MOUNTED" /> <data android:scheme="file" /> </intent-filter> <

Permission to write on SD card android

做~自己de王妃 提交于 2019-11-29 10:23:15
问题 I have a problem writing to the SD card, here is the code: (Sorry about the layout of the code, just copy pased it ) public class SaveAndReadManager { private String result; private String saveFileName = "eventlist_savefile"; public String writeToFile( ArrayList<Event> arrlEvents ){ FileOutputStream fos = null; ObjectOutputStream out = null; try{ File root = Environment.getExternalStorageDirectory(); if( root.canWrite() ){ fos = new FileOutputStream( saveFileName ); out = new

Is there a limit for the number of files in a directory on an SD card?

邮差的信 提交于 2019-11-29 09:31:18
I have a project written for Android devices. It generates a large number of files, each day. These are all text files and images. The app uses a database to reference these files. The app is supposed to clear up these files after a little use (perhaps after a few days), but this process may or may not be working. This is not the subject of this question. Due to a historic accident, the organization of the files are somewhat naive: everything is in the same directory; a .hidden directory which contains a zero byte .nomedia file to prevent the MediaScanner indexing it. Today, I am seeing an

Stream android logcat output to an sd card

浪子不回头ぞ 提交于 2019-11-29 07:11:55
I want to achieve the following but so far, no luck Open a file in the SD Card when the android application first started. Stream the logcat output to the file. When the application exits, stop the logcat streaming. In my ApplicationClass extends Application onCreate() method, I do this wwLogManager.openLogFile(); and here's the code in the openLogFile() private static final String LOGCAT_COMMAND = "logcat -v time -f "; String timestamp = Long.toString(System.currentTimeMillis()); String logFileName = BuildConstants.LOG_LOCATION + "_" + timestamp + ".log"; mLogFile = new File(Environment

Loading drawable from sd card

核能气质少年 提交于 2019-11-29 04:40:24
I'm trying to load a png image as a drawable from my device sd card. I use the following function but it doesn't work: public Drawable getDrawable() { return new BitmapDrawable(imagePath); } The image path is: mnt/sdcard/MyFolder/image.png The app crashes when I try calling that method, how should I load my png image located in my sdcard and cast it into a Drawable object? There is actually a BitmapDrawable constructor straight from file path. The method you are using is depricated. Try: Drawable myDrawable = new BitmapDrawable(getResources(), pathName); If this doesnt work, Try getting a

How can I programmatically format all data on an SD Card?

和自甴很熟 提交于 2019-11-29 02:43:56
How can I programmatically delete data or format the entire SD Card? code to wipe SDCARD public void wipingSdcard() { File deleteMatchingFile = new File(Environment .getExternalStorageDirectory().toString()); try { File[] filenames = deleteMatchingFile.listFiles(); if (filenames != null && filenames.length > 0) { for (File tempFile : filenames) { if (tempFile.isDirectory()) { wipeDirectory(tempFile.toString()); tempFile.delete(); } else { tempFile.delete(); } } } else { deleteMatchingFile.delete(); } } catch (Exception e) { e.printStackTrace(); } } private void wipeDirectory(String name) {