Writing file on ext SD card (KITKAT) - android

My app records voice and a user complains that he is not able to save the recordings on the external SD card (android 4.4.2).
I know the problem with the KITKAT and I work to adjust this, but until then I want a workaround.
I've instructed him to create a folder on ext. sd card: "extSDcard mount name"/Android/data/myAppPackage/files (using the PC connection) and then to go the app and select the recordings dir to point out to the location above He's telling me isn't working this way...I wonder why, since the path is the app private one?
Is there any solution until I will came up with a new app update?

Related

android studio keeps forcing emulated sd card when running on device, cannot stop it

I'm just try to transfer over data from my app to my new cell phone but all the basic apps only lets me transfer the app and none of its data.
I have created a app that lets me store information on my phone in a txt file, but I need to move it to my new phone. I would like to have an export/import function instead of just hardcoding the data into a new version of the app.
Only problem, I cannot access the SD card when I run 'app' from android studio (To the device thru USB). It does not matter if the SD card is installed or not, It just keeps defaulting to an emulated SD card. Tried switching SD's between phones (file not found). I have mostly installed the app thru running in android studio to my phone. Maybe that is why I cannot access the SD card, because a setting is wrong somewhere?
Is there a way to make android studio stop using emulated drives and make it use only physical drives?
if(Environment.MEDIA_MOUNTED.equals(state))
Is always true
Found the files here, but not on my SD card
Tons of variations of:
File myFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "dbimport.txt");
All give the same-
Device Manager:
shell/emulated/0/filename
from app:
Storage/emulated/0/filename

can't read file from android internal storage

Im using a Camera intent to create a picture file in internal storage on android. This picture is saved in the app directory as
/data/data/com.company.app/files/test.png
This works fine, the picture is there.
When I with CCFileUtils then tries to check if the file exists (using js interface):
cc.FileUtils.getInstance().isFileExist("/data/data/com.company.app/files/test.png")
it returns false. Opening the file with CCSprite is totally hopeless too.
The owner and group of the app is the same as the app itself(i.e. "com.company.app"). The read/write permissions of my file is rw-rw-r.
EDIT: Adding information to add information.
The device from which I've extracted the information is a rooted Samsung Galaxy S running Cyanogenmod 11(exact build number: 11-2014112-SNAPSHOT-M12-galaxysmtd) which is built on top of android version 4.4.4.
Its internal storage so its the device own storage. That means it can't be on a sdcard if Im correct, im not sure, but its not removable media anyhow and its not in a sdcard folder on the device.
I've also tried to do the same on a 1+ one running CM11(exact build number: 11.0-XNPH44S). This device is not rooted so I can't check it's filesystem. But it seems to handle it the same way.

Android Internal Storage advice

I am developing an app for University.
I have bought a Nexus 7 google tablet for the task (I wanted a tablet anyway :P)
I need to convert data I record on the app onto a text file that can be moved onto a PC.. Now, from what I can tell android has high security on 'Internal Storage' which is the only type of storage the Nexus 7 has, and I cant seem to be able to write a text file to a folder or anything.. and I can't even find the app's data folder on the windows explorer so I presume its hidden..
It appears its possible with 'External Storage' such as an SD card but the Nexus 7 does not have an SD card slot..
what should I do? Is it possible to be done on the Nexus 7?
All Android devices have "external storage" regardless whether or not they have SD card support (http://developer.android.com/guide/topics/data/data-storage.html#filesExternal). The naming is unfortunately misleading.
If you save your data to app's default external storage, you can access them on a PC in /Android/Data/[your app's package name]/files

SDCard content exist but cant see them

I am having very Strange problem with my Samsung Nexus with Android 4.0.2. I wrote a simple program which basically create file each time user presses a button. My program is working great on other devices where as on Galaxy Nexus Windows/Mac can not see those files on SD card, but when i do adb shell i see all files on SD Card.
I retest this on another Nexus which has Android 4.0.4 but still same result.
What could be the reason?
You probably need to index your files via MediaScannerConnection. Quoting myself from a blog post from last year:
...the MTP contents are not based on the literal contents of external storage. Instead, MTP contents are based on what files have been scanned by MediaScannerConnection. If you write a file to external storage, until and unless that file is scanned by MediaScannerConnection, it will not be visible to users over MTP.
External storage is scanned on a reboot and possibly on a periodic basis. Users can manually force a scan via utilities like SDRescan. However, the best answer is for you to use scanFile() on MediaScannerConnection to update the media database after you close your file. This will make your file immediately available to the user.

write file to sd card and not usb storage

I am developing an application that needs to write files to the SD card. I am using GetExternalStoragePublicDirectory() to determine the directory to write to.
I have two phones I am developing with. On a Google Nexus S, running Android 4.0.4 (Ice cream sandwich) it is returning a directory on the SD card. However, on a Samsung Exhibit 2 running Android 2.3.5, it is writing directly to the USB storage on the phone.
Is there a way to force the SD card?
edit:
I found that getExternalStoragePublicDirectory(), and getExternalStorageDirectory() are always returning "/mnt/sdcard/". This is not actually the mount location for the sd card. On the Samsung Exhibit 2, this is the USB storage location. The card mount location is "/mnt/sdcard/external_sd". Is there a way to return this actual sd location?
I see that the camera and other apps have found a way to do it. The camera app has a "storage" setting with options "phone" and "memory card". If "memory card" is specified, images are actually stored on the sd card.
Is there a way to return this actual sd location?
No, sorry, not in the current Android SDK.
I see that the camera and other apps have found a way to do it.
Mostly, they will either be ones written by the device manufacturer, or are reading information via MediaStore, which should index both sources.
If you want to write to SD card only use
File mySdCardPath = Environment.getExternalStorageDirectory();
File dir = new File (mySdCardPath.getAbsolutePath() + "/yourDirectoryName");

Categories

Resources