android-sdcard

Why don't I have permission to write to app dir on external storage?

≡放荡痞女 提交于 2019-12-03 08:40:47
问题 The TL;DR question summary: My Android app tries to write to the app's external storage directory on an SD card. It fails with a permissions error . But the same code (method), extracted into a minimal test app, succeeds! Since our target API level includes KitKat and later (as well as JellyBean), and KitKat restricts apps from writing anywhere on the SD card except the app's designated external storage directory, the app tries to write to that designated directory, /path/to/sdcard/Android

What is the differnce between accessing file from assets folder or SD card

北战南征 提交于 2019-12-03 08:06:36
I am developing an application where I have to use three different size's file (1mb, 5mb, 15mb). I searched, then came to know that we can keep these video in assets folder and can use those video. Secondly, I came to know that we can keep these videos in assets folder and installation time we can move all videos to SD card. when tried second approach faced problem due to bigger file size. So, can anyone please tell me what is difference between both approaches and which one I should use. Any pointer will be appreciated. Files over 1mb placed in the assets folder won't be readable from your

Take backup of all install apk file into sdcard programmatically in Android [duplicate]

↘锁芯ラ 提交于 2019-12-03 04:38:47
问题 This question already has answers here : How to get the .apk file of an application programmatically (3 answers) Closed 5 years ago . I want to take back up of my all install application in my sdcard so I write below code public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory

How to access /storage/emulated/0/

半世苍凉 提交于 2019-12-03 04:14:24
问题 I have written a code to record audio and save it to below file location. private String getFilename() { String filepath = Environment.getExternalStorageDirectory().getPath(); File file = new File(filepath, AUDIO_RECORDER_FOLDER); if (!file.exists()) { file.mkdirs(); } return (file.getAbsolutePath() + "/" + System.currentTimeMillis() + file_exts[currentFormat]); } In Logcat, it gives me a file location as /storage/emulated/0/AudioRecorder/1436854479696.mp4 I am not able to find this file

Is there a way to get SD Card size in Android?

假如想象 提交于 2019-12-03 03:33:27
Welcome all I have tried every question related to this in Stackoverflow and google and none of them works. I have tried something like this next link, but it returns the same as internal storage: How to get an External storage sd card size (With Mounted SD card)? For example, if I have about 12GB internal storage and 4GB SD card storage, no matter what method I use, I always get the exact same number for the SD space as I do for internal space. It seems that the old methods posted here in Stackoverflow only works until Android KitKat but do not work in next android versions. Is possible to

Force access to external removable microSD card

匆匆过客 提交于 2019-12-03 02:35:23
I'm using a Samsung A3, Android 5.0.2. I'm using this setup to compile apps, i.e. Android 4.1 Jelly Bean (API 16) target. I precisely know the path of the external removable microSD card, it is /mnt/extSdCard/ (see also Note #7 below). Problem: I notice that File myDir = new File("/mnt/extSdCard/test"); myDir.mkdirs(); doesn't work: no directory is created. Also: File file = new File("/mnt/extSdCard/books/test.txt"); // the folder "books" already exists on the external microSD card, has been created from computer with USB connection FileOutputStream fos = new FileOutputStream(file); produces

Bug when listing files with Android Storage Access framework on Lollipop

拜拜、爱过 提交于 2019-12-02 22:39:24
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 can then select any folder/subfolder for sync and I persist the folder document Uri as a string in the

Access sd card in android for uploading a file to my php server using phonegap

本小妞迷上赌 提交于 2019-12-02 19:37:28
问题 I want to go to select a file from sdcard and upload it to server. is it possible to access the sdcard in android via phonegap as how we are picking a image from gallery and uploading. I went through samples but all are specifying the file name also like eg: mnt/sdcard/read.txt. But i want to goto only sdcard so that user can select his own file is it possible to do. 回答1: U can easily do that its very easy window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccessUpload, fail

Take backup of all install apk file into sdcard programmatically in Android [duplicate]

风格不统一 提交于 2019-12-02 17:47:37
This question already has an answer here: How to get the .apk file of an application programmatically 3 answers I want to take back up of my all install application in my sdcard so I write below code public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List pkgAppsList = getPackageManager().queryIntentActivities( mainIntent, 0); for (Object object

How to access /storage/emulated/0/

谁说我不能喝 提交于 2019-12-02 17:31:49
I have written a code to record audio and save it to below file location. private String getFilename() { String filepath = Environment.getExternalStorageDirectory().getPath(); File file = new File(filepath, AUDIO_RECORDER_FOLDER); if (!file.exists()) { file.mkdirs(); } return (file.getAbsolutePath() + "/" + System.currentTimeMillis() + file_exts[currentFormat]); } In Logcat, it gives me a file location as /storage/emulated/0/AudioRecorder/1436854479696.mp4 I am not able to find this file location on my SD card. How to access the location? As Hiren stated, you'll need a file explorer to see