android-sdcard

problem in taking screenshots in android by programmatically

本秂侑毒 提交于 2021-02-08 11:55:25
问题 in my app i am taking screenshot of the current screen and save it in sdcard. but in the case screenshot is not saved in sdcard. how to take screen shot and send the captured screen shot in email as attachment. please help me. my coding: View v1 = view.getRootView(); v1.setDrawingCacheEnabled(true); Bitmap bm = v1.getDrawingCache(); try { System.out.println("path "+Environment.getExternalStorageDirectory()); FileOutputStream out = new FileOutputStream(Environment.getExternalStorageDirectory()

Android - Internal Storage vs External Storage when App installed on SD Card

你离开我真会死。 提交于 2021-02-07 11:39:16
问题 I have an app which downloads large amounts of content (it varies between users but could be 200mb to 1GB or more). Currently I save all of this content on External Storage as this is likely to be the area with the most space, such as an SD card. This works fine for the most part however there is a situation where this isn't necessarily ideal. If the device has in built external storage, like most tablets, but also has an SD card slot, the external storage issue gets a little complicated. The

Android - Internal Storage vs External Storage when App installed on SD Card

走远了吗. 提交于 2021-02-07 11:39:07
问题 I have an app which downloads large amounts of content (it varies between users but could be 200mb to 1GB or more). Currently I save all of this content on External Storage as this is likely to be the area with the most space, such as an SD card. This works fine for the most part however there is a situation where this isn't necessarily ideal. If the device has in built external storage, like most tablets, but also has an SD card slot, the external storage issue gets a little complicated. The

Sharing images in other application

谁都会走 提交于 2021-01-29 18:19:00
问题 I have application with images and I want share image which is choosen by user in some other application. From other question here I know that I must put the image in public place so it can be accesed by other application. But I still get error "no application can perform this action" any idea where am I doing mistake? Code for copying image to SD card: String path = Environment.getExternalStorageDirectory().toString(); File file = new File(path,String.valueOf(idOfImage)); if (!file.exists())

Android - ask write to SD card permission dialog

穿精又带淫゛_ 提交于 2020-07-18 16:23:17
问题 I am having trouble gaining write access to device SD card root directory. I can write to device internal storage and app package folder in an SD card without problems. I found that gaining access to an SD card is possible using Storage Access Framework, so I looked at other apps to see how they gain access to an SD card, and found Total Commander with its neat permission dialog. How to show such a dialog because I cannot find any examples? My goal is to store large files on the SD card that

Android - ask write to SD card permission dialog

流过昼夜 提交于 2020-07-18 16:21:59
问题 I am having trouble gaining write access to device SD card root directory. I can write to device internal storage and app package folder in an SD card without problems. I found that gaining access to an SD card is possible using Storage Access Framework, so I looked at other apps to see how they gain access to an SD card, and found Total Commander with its neat permission dialog. How to show such a dialog because I cannot find any examples? My goal is to store large files on the SD card that

Save .txt file on Android Q

我只是一个虾纸丫 提交于 2020-06-01 06:52:32
问题 I was trying to save text file using below code try { FileOutputStream fos = new FileOutputStream(TXT_FILE_NAME, true); FileWriter fWriter; try { fWriter = new FileWriter(fos.getFD()); fWriter.write(binding.tvExtractedResult.getText().toString()); fWriter.close(); } catch (Exception e) { e.printStackTrace(); } finally { fos.getFD().sync(); fos.close(); Toast.makeText(this, "File Saved Successfully", Toast.LENGTH_LONG).show(); } } catch (Exception e) { Toast.makeText(this, "Error while saving

Save .txt file on Android Q

牧云@^-^@ 提交于 2020-06-01 06:52:25
问题 I was trying to save text file using below code try { FileOutputStream fos = new FileOutputStream(TXT_FILE_NAME, true); FileWriter fWriter; try { fWriter = new FileWriter(fos.getFD()); fWriter.write(binding.tvExtractedResult.getText().toString()); fWriter.close(); } catch (Exception e) { e.printStackTrace(); } finally { fos.getFD().sync(); fos.close(); Toast.makeText(this, "File Saved Successfully", Toast.LENGTH_LONG).show(); } } catch (Exception e) { Toast.makeText(this, "Error while saving

Image Save to SdCard for 6.0.1 Android Version

别说谁变了你拦得住时间么 提交于 2020-03-06 08:55:30
问题 This code works correctly under 6.0.1 android version but if i run this application on 6.0.1 android devices , it will not save images to sd card. What i need to update for 6.0.1 devices ? public void SaveImages(int a ,String b) { Bitmap bitmap = null; OutputStream output; if(a==0) { bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.image_0); } File filepath = Environment.getExternalStorageDirectory(); // Create a new folder in SD Card File dir = new File(filepath

Record audio and play it afterwards

戏子无情 提交于 2020-03-06 02:38:48
问题 I wrote a class that shall make it possible to record an audio, save it to the sd card and then play the result. Here is my code: public void recordAudio(final String fileName) { final MediaRecorder recorder = new MediaRecorder(); recorder.reset(); ContentValues values = new ContentValues(3); values.put(MediaStore.MediaColumns.TITLE, fileName); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder