android-sdcard

how to hide images from android gallery

房东的猫 提交于 2019-11-27 19:18:21
问题 One part of my current project is downloading images from URL then saving to SDCard. But the problem is all of saved images in sdcard is displayed in android gallery page. What I want is " I don't want all of my saved images in android gallery. " 回答1: Add ".nomedia" file. Did not work? Try the second option. Save your files to a folder that starts with ".", e.g., /sdcard/.myimages/ 回答2: You can create .nomedia file using this code: String NOMEDIA=".nomedia"; File Folder = new File(Environment

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

佐手、 提交于 2019-11-27 19:09:42
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 Windows, I can't see the file! Now, if I go to Settings → Applications → Manage Applications → "Force

Unable to write files on sdcard android

时间秒杀一切 提交于 2019-11-27 18:42:13
问题 I have an app which saves backup files on SD-Card. It works fine on HTC Nexus One, and other android phones, but with some phones it doesn't work (reading or writing). In the manifest I have set this: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> For example (when I set the path for recording file) : OutputStream output = new FileOutputStream(Environment.getExternalStorageDirectory() + "/mydata.dat"); //Writing file...(It doesn't work) How I can get the right

Removable storage (external) sdcard path by manufacturers

我是研究僧i 提交于 2019-11-27 18:09:02
I've been Googling around but it is sooooo hard to find what manufacturers/models use which path for sdcard/external storage. I am NOT talking about the internal storage path which can be found by: Environment.getExternalStorageDirectory() I know that getExternalStorageDirectory() sometimes points to external sdcard on some devices. Here's what I've found some common path for external path (Not sure which manufacturer uses which path): /emmc /mnt/sdcard/external_sd /mnt/external_sd /sdcard/sd /mnt/sdcard/bpemmctest /mnt/sdcard/_ExternalSD /mnt/sdcard-ext /mnt/Removable/MicroSD /Removable

Environment.getExternalStorageDirectory().getAbsolutePath() gives a different path - Android

╄→尐↘猪︶ㄣ 提交于 2019-11-27 16:17:35
问题 I try to write something into my phone memory. At first, I hard-coded the path as: myFile = new File("/sdcard/" + txtName.getText() + ".txt"); This works totally ok. And then, eclipse gives me a warning saying that I shouldn't have hard-coded the path like that instead, I should do the following: myFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/"+ txtName.getText() + ".txt"); Then I follow the correction suggestion and avoid the warning. However, I encountered

Restoring SQLite DB file

雨燕双飞 提交于 2019-11-27 15:23:01
问题 I'm implementing a backup/restore system in my android app. An automatic backup occures every couple of minutes. I'm trying to restore my db backup file from my sd card, after my app was uninstalled and then installed again. Backup works, but here's the problem: Whenever the user installs my app again, there's a file not found exception, but, if the user closes the app, and then opens it again, the restore is just fine. Somehow, the restoring faces problem when the app is first launched. The

List out all images from SD card.

六月ゝ 毕业季﹏ 提交于 2019-11-27 14:32:21
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 for count if (listFiles.length > 0) { for (int i = 0; i < listFiles.length; i++) { String filePath =

I want to set an image saved on sd card in main layout background through my application

帅比萌擦擦* 提交于 2019-11-27 14:26:06
问题 i am creating an application in which i want set different background images in main xml linearlayout.I have stored 5 image files on sd card .now i want to select a pic and set it as my maim xml linearlayout background.so it will replace the previous image and display the new image as background. 回答1: First assign an id to the main xml linearlayout, for example in the following case it is named" container" <!-- main.xml --> <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=

Format SD card in Android

本小妞迷上赌 提交于 2019-11-27 14:06:20
问题 Things should be simple, but as most of the time, in Android, aren't. I need to format the SD card if the user selects the option in my app. Don't ask me why I need to do this if it's already in the OS... not practical but it's a requirement that I need to implement. As you may know, there is an option in Settings \ Storage \ Erase SD Card . I took a look at the froyo source code and it's something like: final IMountService service = IMountService.Stub.asInterface(ServiceManager.getService(

How to get random access to a file on SD-Card by means of API presented for Lollipop?

折月煮酒 提交于 2019-11-27 14:01:56
问题 My application uses Java class RandomAccessFile to read/write bytes to a file on SD card randomly by means of realization of SeekableByteChannel interface. Now I need rewrite it for Android 5.0 with new Lollipop API. I have found the only way to read: InputStream inputStream = getContentResolver().openInputStream(uri); and write: ParcelFileDescriptor pfd = getActivity().getContentResolver().openFileDescriptor(uri, "w"); FileOutputStream fileOutputStream = new FileOutputStream(pfd