android-sdcard

Device claims external storage, yet I have no SD card

最后都变了- 提交于 2019-11-29 14:59:17
Samsung galaxy S3 with no SD card, I'm using this code to check storage states. Using this code: boolean mExternalStorageAvailable = false; boolean mExternalStorageWriteable = false; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // We can read and write the media mExternalStorageAvailable = mExternalStorageWriteable = true; } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { // We can only read the media mExternalStorageAvailable = true; mExternalStorageWriteable = false; } else { // Something else is wrong. It may be one of

Writing to internal SD card on Android

拈花ヽ惹草 提交于 2019-11-29 14:41:42
Is there any way of accessing the internal SD card on Android devices that have internal flash, internal SD and external SD cards? 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 no standard APIs to get to other partitions or cards. A device manufacturer might document how to access

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

不羁的心 提交于 2019-11-29 14:34:16
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 the specific image into the library. That works great for one image, but when the .nomedia file is

Android external sdCard DCIM folder path

早过忘川 提交于 2019-11-29 14:20:01
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? Try out with String m_path = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_DCIM).getAbsolutePath(); For the more details about the storage file structure you check my Blog The answer is here in the API Guide: http://developer.android.com/guide/topics/data/data-storage

Android Storage Locations

♀尐吖头ヾ 提交于 2019-11-29 14:11:15
Can someone explain in detail about the various storage locations in Android, /sdcard/ (along with /root/ directory and other system-level directory) /storage/emulated/0/ /storage/emulated/legacy/ /storage/sdcard0/ Really confused with these? And are there any methods to access them programatically whenever needed? AnV I can't speak for storage paths on all phones. But I can explain you clearly with respect to my phone; Coolpad Note 3 - running on Android 5.1. Because, the storage locations or paths may vary on other mobile phones depending on your vendor/manufacturer and different versions of

How to sort files using datetimestamp

孤街醉人 提交于 2019-11-29 12:56:05
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(new ImageAdapter(this)); } public static List <String> getSD() { List <String> it = new ArrayList

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

女生的网名这么多〃 提交于 2019-11-29 12:45:21
How to check the type of sdcard's filesystem? For example, in Windows we can see NTFS, FAT32, exFAT, etc. Thanks in advance. 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 = bufferedReader.readLine()) != null) { String[] split = line.split("\\s+"); for(int i = 0; i < split.length -

Android: How to access a file in the SD Card

点点圈 提交于 2019-11-29 08:13:14
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") Try like this: String SD_CARD_PATH = Environment.getExternalStorageDirectory().toString(); new File(SD_CARD_PATH + "/" + "splah2.jpg"); Lior Ohana Try running: new File(Environment.getExternalStorageDirectory() + "/splah2.jpg") try this, File f=new File("/sdcard/splah2.jpg"); The code below has worked for me. String mRelativeFolderPath = "/DCIM/Camera/"; // i.e. SDCard/DCIM/Camera String

Building a Utility to get the path to External Removable storage every time

时光怂恿深爱的人放手 提交于 2019-11-29 08:00:21
Recently, I needed to be able to write some data strictly on a phone's external, removable storage (aka SDCard). For lower-end devices without "external" internal storage (you know what I mean), this isn't an issue as Environment.getExternalStorageDirectory().getAbsolutePath() , which returns /mnt/sdcard is also the path to the sdcard. However on higher-end phones with built-in flash storage (sgs 2 for example), /mnt/sdcard , which is returned from Environment.getExternalStorageDirectory().getAbsolutePath() , is just the path to the internal storage. The real path to the sdcard is ` /mnt

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

有些话、适合烂在心里 提交于 2019-11-29 07:46: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 work. Runtime.getRuntime().exec("chmod 777 /data/data"); I want to do a backup program and i want to