android-sdcard

Android source error reading file from sdcard

爷,独闯天下 提交于 2019-12-12 14:35:22
问题 I'm modifying the Android source (AOSP) to create a file /sdcard/myfile . The file is created properly and is visible when I do a cat /sdcard/myfile from adb shell . (The file is created from PackageManagerService which is part of the application framework layer) However, when I try to access the file through code using new FileReader(myfile) from the same package manager service code, I get the following exception: java.io.FileNotFoundException: /sdcard/myfile (Permission denied) The

Is There A Way To Store SharedPreferences to SDcard?

前提是你 提交于 2019-12-12 13:41:25
问题 I've written an app that has several hard-coded settings such as fontSize or targetDirectory. I would like to be able to change those type of settings on an infrequent basis. SharedPreferences seems to be one way to go about it but I want to share this application and settings, and my phone is not rooted. My application is a personal tool, and does not have a UI. It opens, does it's job, and then closes. I could create the equivalent of a Windows .ini file and read/write to it, but that seems

Android SD card issues

对着背影说爱祢 提交于 2019-12-12 10:38:49
问题 I currenlty have a few problems with developing an APP and using the external SD card. The first problem is that I check if there is a SD card mounted. This function returns a true even if there is no SD card inserted. I've used/tried the following code: https://stackoverflow.com/a/12721994 http://tsicilian.wordpress.com/2012/04/24/android-persistence-external-storage-sd-card/ from developer.android.com Every Android-compatible device supports a shared "external storage" that you can use to

Open folder on card

安稳与你 提交于 2019-12-12 07:23:53
问题 I thought this was something really simple, but it's giving me more work than the rest of the whole app. I just want a button to open the "Downloaded Files" folder of my app. That's all. No file picker, nothing complicated. All the button has to do is open a folder with the default app (or open the app chooser if there's no default). I tried different solutions I saw here on StackOverflow, but nothing seems to work for me. Example 1: Intent intent = new Intent(Intent.ACTION_GET_CONTENT); Uri

Delete copy of an image in sdcard

十年热恋 提交于 2019-12-12 07:07:57
问题 Hello friends I am using the following code in my my project. PERMISSIONS: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.CAMERA"/> XML FILE: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="wrap_content" android:layout

embed a image in email body from saving and picking in sdcard in android

倖福魔咒の 提交于 2019-12-12 03:59:31
问题 I'm trying to embed a inline image in email body by saving in sdcard and then picking from that place but image is not being shown and just "obj" is shown there.Kindly help me out,here is the code of my function: { Bitmap newImg=BitmapFactory.decodeByteArray(img,0,img.length); String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + "/saved_images"); myDir.mkdirs(); String fname = "stoneage.jpg"; File file = new File (myDir, fname); try{

Get Persistable SD Cad write Permission using SAF

纵饮孤独 提交于 2019-12-12 03:52:34
问题 In my application, list of Image files is inflated in recyclerview. Then after application edits the metadata of Image file. My code for writing metadata:- DocumentFile fos = DocumentFile.fromFile(new File(fileIn)); ByteSource bytsInputStream = new ByteSourceFile(new File(fileIn)); byte[] byteArrayInputStream = bytsInputStream.getAll(); try { ParcelFileDescriptor pfd = context.getContentResolver(). openFileDescriptor(fos.getUri(), "w"); FileOutputStream fileOutputStream = new FileOutputStream

why only 1 of 10 image is load and saved in sd card

只愿长相守 提交于 2019-12-12 03:49:41
问题 I am loading 10 Images from URL's that are stored in array . only last index url is loading and saving image in SD card . here is my code : for(int j=0; j<List.size();j++) { reviewImageLink =List.get(j).get(TAG_Image).toString(); URL reviewImageURL; String name = reviewImageLink;//.substring(reviewImageLink .lastIndexOf("/") + 1,reviewImageLink.length()); try { reviewImageURL = new URL(reviewImageLink); if (!hasExternalStoragePublicPicture(name)) { isImage = false; new DownloadImageTask()

get Root directory (i.e external or external sdcard) from file path

徘徊边缘 提交于 2019-12-12 03:04:15
问题 I am facing a situation to calculate the free size of the currently selected primary memory(i.e external or external sdcard). All i have is the file path in app specific folder like below "/root/extsdcard/Android/data/com.a.b/files/img0001.jpg"; or "/root/ext/Android/data/com.a.b/files/img0001.jpg"; How i can get the path "/root/extsdcard/" or "/root/ext/" respectively from above shown paths? 回答1: Just mention "/" for root directory e.g. File File f=new File("/"); String files[]= f.list(); 来源

List all text files present on SD card

 ̄綄美尐妖づ 提交于 2019-12-12 00:35:04
问题 I am using the following code to list down all the files present on the SD card. However I just want to list down all the text files can some body tell me how to add a file filter. Similarly I need to fetch the image files as well. Following is my code: public ArrayList<String> GetFiles(String DirectoryPath) { ArrayList<String> MyFiles = new ArrayList<String>(); File f = new File(DirectoryPath); f.mkdirs(); File[] files = f.listFiles(); if (files.length == 0) return null; else { for (int i=0;