sd-card

Using the camera intent to take a picture without an sdcard

末鹿安然 提交于 2019-12-11 09:47:26
问题 I'm having trouble using the camera when there's no sdcard present. When there is an sdcard, using the camera is trivial, e.g. http://www.vogella.com/articles/AndroidCamera/article.html + a plethora of other examples. However, I need to make my app available to devices which don't have SD cards, (e.g. the Sony Xperia series.) I've tried modifying the code such that I'm using the internal storage (I think): Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = new File

display videos from specific folder from sd card in listview

南笙酒味 提交于 2019-12-11 07:36:48
问题 i am trying to populate listview with video files from a folder created on sd card. I am using managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,mystring, null, null, null); But it populates all videos saved in sdcard, but i want only those videos which are saved in specific folder. I have also used Uri uri = Uri.fromFile(filepath); cursor = managedQuery(uri, mystring , null , null , null); and Uri uri = Uri.parse(filepath); cursor = managedQuery(uri, mystring , null , null , null);

How to copy assets sub-folders files on sd-card in android

廉价感情. 提交于 2019-12-11 05:52:17
问题 I want to copy the files and folders of my assets folder on a specified folder on sd-card. Here's my code: private void copyFiles() { AssetManager assetManager = getAssets(); InputStream in = null; OutputStream out = null; try { String files[] = assetManager.list("Files"); for (String fileName : files) { Log.d("File name =>", fileName); in = assetManager.open("Files/" + fileName); out = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyApp/Files/" +

Can you write to the sdcard folder when there is no sdcard?

我们两清 提交于 2019-12-11 05:36:33
问题 So I'm testing an app on a galaxy s3 on 4.1 and an older phone that runs 2.3. Neither phone has an sdcard in it but when I use Environment.getExternalStorageDirectory().getAbsolutePath() on my galaxy s3 it directs me to a folder called sdcard0 within a folder called storage. When I run it on the older phone it gives me the path mnt/sdcard/ and the sdcard folder is read only. I am trying to create a folder in these directories. I can do it on my s3 but not on my older phone. Is there something

Android - Sdcard doesn't create / copy a file

坚强是说给别人听的谎言 提交于 2019-12-11 04:56:19
问题 I am having some problems copying a file from a folder to other folder; both are in SDCard. I want to copy from /sdcard/folder1/file.db to /sdcard/folder1/folder2 (creating if doesn't exist) /file.db AndroidManifest.xml <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> My code public void realizarBackup() { String nombrebd = "BRSAndroid.db"; File sd = new File(Environment.getExternalStorageDirectory().getPath()); if (sd.exists() && sd.canWrite()){

BitmapFactory.decodeStream causing “read failed: EBADF (Bad file number)” error

泪湿孤枕 提交于 2019-12-11 04:14:19
问题 I have a piece of code where use a 2-stage image loading for loading images from the SDCard. First I use the method BitmapFactory.decodeStream to just decode the image bounds and after I use it to really load the (sampled) image. Here is my method. I think it's derived from an example I saw here someday, but I don't remember the thread. public static Bitmap decodeSampledBitmapFromStream(Context c, Uri uri, int reqWidth, int reqHeight) throws IOException { FileInputStream fis = getSourceStream

Why sdcard legacy getCanonicalPath not emulated/0 in Android 4.2 OS?

牧云@^-^@ 提交于 2019-12-11 00:52:38
问题 run adb shell, look for the legacy link to /mnt/shell/emulated/0 But getCanonicalPath can't get /mnt/shell/emulated/0? shell@android:/storage/emulated $ ls -l lrwxrwxrwx root root 2012-12-07 12:01 legacy -> /mnt/shell/emulated/0 File file = new File("/storage/emulated/legacy"); String pachString = null; try { pachString = file.getCanonicalPath(); // prints /storage/emulated/legacy } catch (IOException e) { e.printStackTrace(); } 回答1: shell@android: /mnt $ ls -l /mnt/ ls -l /mnt/ drwxr-xr-x

How should I refer to “external storage” in the UI on Android?

邮差的信 提交于 2019-12-10 23:56:11
问题 Apparently external storage on Android (referred to by Environment.getExternalStorageDirectory) doesn't have to be an SD card. In fact, it doesn't even have to be external! How can I refer to this storage in the UI? For example, if it is currently not accessible, I want to surface an error to the user. If I say "external storage" or "SD card", I may confuse users of some devices. Is there a way to appropriately identify it? 回答1: A look at the docs for Environment.getExternalStorageDirectory()

Display video files in listview from sdcard folder

末鹿安然 提交于 2019-12-10 21:35:13
问题 I am trying to display video files in listview from folder 'abc' on sdcard, i have successfully displayed but problem is that it displays all video files stored on sdcard even out of folder 'abc' actually i want only video files stored in folder 'abc' to be displayed. I am googling since more days but didn't find any solution for that. My code is: videocursor = managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, proj, null, null, null); count = videocursor.getCount(); videolist =

Sending SD commands from Android app

故事扮演 提交于 2019-12-10 19:19:34
问题 Is it possible to send SD (Secure Digital) commands from Android app to SD card ? Commands are read SD card, write to SD card etc (CMD18, CMD24). The constraint is the phone should NOT be a rooted phone. With rooted phone we are able to send SD commands but not with unrooted phone. On attempting we get the error "permission denied". Any help is greatly appreciated. Thanks 回答1: It is not possible. The SD card hardware is abstracted away and mounted as a directory in the filesystem. Why would