android-sdcard

Can't see a file in Windows written by an Android app on SD card unless I “Force Close” the app

ぐ巨炮叔叔 提交于 2019-11-26 19:46:58
问题 I wrote a file through my Android program like this: String file = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Files/hello.txt"; BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.write(str + "\n"); \\ Yeah, 'str' has a value there writer.close(); The program does its job and it finishes. Now I hit the back button on Android to close the application. If I then go to an Android file browser (like Astro) I can see the file, but if I mount the SD card on

Android: Display Image from SD CARD

余生长醉 提交于 2019-11-26 18:58:45
This is driving me insane! Here's my code (I know this file exists): File imageFile = new File("/sdcard/gallery_photo_4.jpg"); ImageView jpgView = (ImageView)findViewById(R.id.imageView); BitmapDrawable d = new BitmapDrawable(getResources(), imageFile.getAbsolutePath()); jpgView.setImageDrawable(d); The error occurs on that last line (line 28, referenced below). Error output: W/dalvikvm( 865): threadid=1: thread exiting with uncaught exception (group=0x4001d800) E/AndroidRuntime( 865): FATAL EXCEPTION: main E/AndroidRuntime( 865): java.lang.RuntimeException: Unable to start activity

Displaying images from a specific folder on the SDCard using a gridview

南楼画角 提交于 2019-11-26 18:52:26
I'm attempting to create a gridview that is loaded with images from a specific folder that resides on an SDCard. The path to the folder is known, ("/sdcard/pictures") , but in the examples I've seen online I am unsure how or where to specify the path to the pictures folder I want to load images from. I have read through dozens of tutorials, even the HelloGridView tutorial at developer.android.com but those tutorials do not teach me what i am seeking. Every tutorial I have read so far has either: A) called the images as a Drawable from the /res folder and put them into an array to be loaded,

List out all images from SD card.

被刻印的时光 ゝ 提交于 2019-11-26 18:25:05
问题 Hi I am developing android Gallery app . I am fetching the images from a folder in sd card and displaying it on a grid view as below public static ArrayList<String> getFilePaths() { ArrayList<String> filePaths = new ArrayList<String>(); File directory = new File(android.os.Environment.getExternalStorageDirectory() + File.separator + AppConstant.PHOTO_ALBUM); // check for directory if (directory.isDirectory()) { // getting list of file paths File[] listFiles = directory.listFiles(); // Check

Android Open External Storage directory(sdcard) for storing file

随声附和 提交于 2019-11-26 17:19:54
I want to open external storage directory path for saving file programatically.I tried but not getting sdcard path. How can i do this?is there any solution for this?? private File path = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + ""); or private File path = new File(Environment.getExternalStorageDirectory() + ""); I tried getting path from above both methods but both are pointing internal memory. When we open storage memory if sdcard is peresent it will shows like below- device storage & sd memory card. I want to get sd memory path through coding.

SQLite database on SD card

ぐ巨炮叔叔 提交于 2019-11-26 16:27:50
问题 I'm looking to create a sqlite database on the sd card (don't want to use up the user's internal storage). I'm familiar with the OpenHelper pattern: public DatabaseFoo(Context context) { OpenHelper openHelper = new OpenHelper(context); mDb = openHelper.getWritableDatabase(); } private static class OpenHelper extends SQLiteOpenHelper { public OpenHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } ... so if we want to create on the sd card, I think instead we

How to tell if the sdcard is mounted in Android?

谁说我不能喝 提交于 2019-11-26 16:20:59
I'm working on an Android application that needs to look at what images a user has stored. The problem is that if the user has the sdcard mounted via the USB cable, I can't read the list of images on the disk. Does anyone know of a way to tell if the usb is mounted so that I could just pop up a message informing the user that it won't work? If you're trying to access images on the device, the best method is to use the MediaStore content provider . Accessing it as a content provider will allow you to query the images that are present, and map content:// URLs to filepaths on the device where

Universal way to write to external SD card on Android

别等时光非礼了梦想. 提交于 2019-11-26 14:53:52
In my application, I need to store lots of images in the device storage. Such files tend to fulfill the device storage, and I want to allow users to be able to choose external SD card as the destination folder. I read everywhere that Android doesn't allow users to write to external SD card, by SD card I mean the external and mountable SD card and not the external storage , but file manager applications manage to write to External SD on all Android versions. What is the better way to grant read/write access to external SD card on different API levels (Pre-KitKat, KitKat, Lollipop+)? Update 1 I

How to make a file hidden in android sd card?

别说谁变了你拦得住时间么 提交于 2019-11-26 14:48:44
问题 I am creating android application which contains DB that needs to be hidden(not able to access by the user)in the SD Card. Can anyone tell me how to do this? 回答1: Any file stored on the SD card is accessible both by applications running on the phone, and by users who have mounted the SD card (both while it's in the phone and otherwise). You can change the file properties to make it 'hidden', but it will still be easily found. There is no way to make a file on a public partition like an SD

reading a specific file from sdcard in android

邮差的信 提交于 2019-11-26 14:35:42
how to read a specific file from sdcard. i have pushed the file in sdcard through DDMS and i am trying to read it though this way but this give me exception. can anybody tell me how to point exactly on that file? my code is this. String path = Environment.getExternalStorageDirectory().getAbsolutePath(); FileInputStream iStream = new FileInputStream(path); You are trying to read a directory... what you need is the file! Do something like this... then, you can read the file as you want. File dir = Environment.getExternalStorageDirectory(); File yourFile = new File(dir, "path/to/the/file/inside