android-sdcard

Why getExternalFilesDirs() doesn't work on some devices?

喜你入骨 提交于 2019-11-28 10:07:37
My app runs on Android 5.0. I use method getExternalFilesDirs() to check if external SD card is available. If it returns more than 1 File , that means external SD card exists. But on some devices (for example Elephone G2), method getExternalFilesDirs() returns only one directory of primary storage. I'm sure that device has external SD card (/storage/sdcard1/). Can any one give me the answer? For getExternalFilesDirs to return the path of the sdcard, the OEM must have set the SECONDARY_STORAGE environment variable in the device specific init.rc file as mentioned here: https://source.android.com

Android picture saved to SD card not showing in Gallery

雨燕双飞 提交于 2019-11-28 09:52:42
问题 Currently I have a program that takes pictures and saves them as a jpg on the top level of the sdcard, but its not appearing in the Gallery. Is there something I must do to make it happen? 回答1: You need to call the MediaScanner so that it knows your file exists: File file; // = your file String mimetype; // = your file's mimetype. MimeTypeMap may be useful. MediaScanner.scanFile(getApplicationContext(), new String[]{file.getPath()}, new String[]{mimetype}, null); 回答2: Try this answer. Working

Write file to sdcard in android

て烟熏妆下的殇ゞ 提交于 2019-11-28 08:42:28
问题 I want to create a file on sdcard. Here I can create file and read/write it to the application, but what I want here is, the file should be saved on specific folder of sdcard. How can I do that using FileOutputStream ? // create file public void createfile(String name) { try { new FileOutputStream(filename, true).close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace();

On Android: How can I rescan an entire folder to watch for changes in .nomedia

倾然丶 夕夏残阳落幕 提交于 2019-11-28 08:32:08
问题 So my app downloads images at the users' request from an online source. Through a button in the activity, the user can choose to hide or show the images in the gallery. This is easy enough, I just add or remove a .nomedia file as needed. However, I want to rescan media every time so that the change is instant, and requires no further user interaction. After each image is downloaded, I am using the method at http://www.mail-archive.com/android-developers@googlegroups.com/msg24164.html to scan

Writing to internal SD card on Android

心不动则不痛 提交于 2019-11-28 08:31:23
问题 Is there any way of accessing the internal SD card on Android devices that have internal flash, internal SD and external SD cards? 回答1: In Android 2.2 and previous, there is only one "external storage" ( Environment.getExternalStorageDirectory() ). The definition of where this points is up to the device manufacturer. The Compatibility Definition Document (CDD) merely mandates that it be at least 2GB, IIRC. It is not even required for "external storage" to be removable. At this time, there are

External SDCard file path for Android

橙三吉。 提交于 2019-11-28 08:24:25
Is it true that the file path to external SDCard on Android devices are always "/storage/extSdCard" ? If not, how many variations are there? I need it for my App to test the availability of external SDCard. I am using Titanium, it has a method Titanium.Filesystem.isExternalStoragePresent( ) but it always return true even external SDCard is not mounted. I think it detect SDCard at local storage thus return true. But what I really want is detect whether physical SDCard is mounted or not. Can I do this by detecting the existence of file "/storage/extSdCard" alone? Thanks. Digoun Is it true that

Android external sdCard DCIM folder path

痴心易碎 提交于 2019-11-28 08:01:32
问题 I need the DCIM folder path from the external sdCard if it is present. I have observed that this path changes according to the manufacturer of the device ("/storage/extSdCard", "/storage/SdCard", "mnt/storage/extSdCard", ...) Is there any Android api that would give me the path irrespective of the device? 回答1: Try out with String m_path = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_DCIM).getAbsolutePath(); For the more details about the storage file structure you

Android 5.0 DocumentFile from tree URI

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 07:44:05
Alright, I've searched and searched and no one has my exact answer, or I missed it. I'm having my users select a directory by: Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, READ_REQUEST_CODE); In my activity I want to capture the actual path, which seems to be impossible. protected void onActivityResult(int requestCode, int resultCode, Intent intent){ super.onActivityResult(requestCode, resultCode, intent); if (resultCode == RESULT_OK) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M){ //Marshmallow } else if (android.os

How to sort files using datetimestamp

最后都变了- 提交于 2019-11-28 06:39:30
问题 I am capturing images , then storing into SD Card and showing in a List , but here i need a small change, still i am getting old on top and latest at bottom , so now i want to show latest picture on the top on the basis of datetimestamp using as a part of file name. UploadActivity.java code:- String fileName; static List <String> ImageList; /*** Get Images from SDCard ***/ ImageList = getSD(); // ListView and imageAdapter lstView = (ListView) findViewById(R.id.listView1); lstView.setAdapter

How do I check the type of sdcard's filesystem?

时光总嘲笑我的痴心妄想 提交于 2019-11-28 06:36:13
问题 How to check the type of sdcard's filesystem? For example, in Windows we can see NTFS, FAT32, exFAT, etc. Thanks in advance. 回答1: One solution is to run the mount command then do some string processing on the result: try{ Process mount = Runtime.getRuntime().exec("mount"); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(mount.getInputStream())); mount.waitFor(); String extPath = Environment.getExternalStorageDirectory().getAbsolutePath(); String line; while ((line =