android-file

Simultaneously write and read a file from NDK in android

那年仲夏 提交于 2019-12-12 04:22:29
问题 I am writing into a file using android-ndk . So writing in file is taking place using native c code. It contains some kind of readings that i am putting in using ndk. On click of a button the writing into a file start. And simultaneously i want to read contents of file and use them into another thread for showing up the values as writing operation might continue for 15 sec and user will have to wait for that much time to see the result so i want to show result one by one as soon as i get it

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(); 来源

Get resource ID from URI or Bitmap

时间秒杀一切 提交于 2019-12-12 02:02:45
问题 Is there anyway I can find resource ID from Bitmap, URI, file path or file name of an image? These images are written by my app. So is there any chance I can find the resource ID? Basically, I have GIF images stored in my SD Card (which are created by my app). I want to load those images to my viewer. For that, I am using GIF Movie View library. In that file, setMovieResource() expecting an int (resource ID). But I have all other info like bitmap, absolute path. 回答1: Resource IDs are

How to pick all files from folders and subfolders in Android? [duplicate]

你离开我真会死。 提交于 2019-12-12 01:45:11
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Recursively list files in Java I have created one folder named SlideShow in sdcard. Inside this folder i created two folders namely folder1 and folder2. These two folders further divided into two subfolders each. I am saving some images from gallery into these subfolders. Anyone suggest me how to list all the images from the SlideShow folder including the folders and subfolders ?? 回答1: I think that you can use

Writing to and Reading from a file in Android

我的梦境 提交于 2019-12-11 18:17:28
问题 I am having a hard time figuring out how to write to and read from files on an Android device. The file will be formatted as XML and I already have parsers and data structures built that can format the XML into objects and objects into XML, but the last hurdle is reading the XML from a non-resource file (I know the data structures work because I it works when reading from a resource file) and also writing to a non-resource file. I am terrible at using tools to debug (not sure how to print a

Convert File to DocumentFile

亡梦爱人 提交于 2019-12-11 17:47:33
问题 I want to convert File ( /storage/A54E-14E9/bp.mp4 ) to DocumentFile Uri of DocumentFile should be content://com.android.externalstorage.documents/tree/A54E-14E9%3A/document/A54E-14E9%3Abp.mp4 but when I use DocumentFile.fromFile(file).getUri() it returns not correct Uri : file:///storage/A54E-14E9/bp.mp4 So it's different than when you get it in onActivityResult after calling startActivityForResult(new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE), REQUEST_CODE_STORAGE_ACCESS); @Override

Android XML reading issue (canRead() = false)

我的梦境 提交于 2019-12-11 15:12:16
问题 I've a problem with reading a XML file in my APP. I've tried multiple options but I'm getting error that read acces is false. I'm sure I'm using the correct path. XML = new File(XML, "file.xml"); Log.i("XML", "Read access:" + XML.canRead()); This does return a false, I only need to read not to write (at least, not yet..). System.getProperty(XML.getPath()) Returns null I think there is a problem with the SD card (see other issue). But in my app I can open diffent folders except the XML file in

Appending Two Mp3 files in Android

℡╲_俬逩灬. 提交于 2019-12-11 13:10:58
问题 How can i append two audio files in android. I tried this but it does not work. pls give me a soln.I need to concatenate the files from sdcard that ts A.mp3 and B.mp3 .When i merge concatenate method calls i want both of them as a single file in sdcard that is C.mp3........ File original= new File("/mnt/sdcard/A.mp3"); File temp=new File("/mnt/sdcard/B.mp3"); Log.i("...............",""+path); try { File outFile= new File("/mnt/sdcard/C.mp3 "); DataOutputStream out=new DataOutputStream(new

How to retrieve an image from memory card in this scenario

流过昼夜 提交于 2019-12-11 12:54:26
问题 i am saving an image by passing a bitmap to the savephoto(Bitmap function) now i want to retrieve the photo which is saved ,, how to do that i am new in android , plz give me the code of retrival and also convert it into Bitmap public void savePhoto(Bitmap b2) { File imageFileFolder = new File(Environment.getExternalStorageDirectory(),"Rotate"); mageFileFolder.mkdir(); FileOutputStream out = null; Calendar c = Calendar.getInstance(); String date = fromInt(c.get(Calendar.MONTH)) + fromInt(c

How to read a config file which is under app folder

无人久伴 提交于 2019-12-11 11:26:49
问题 I am having a config fie config.properties inside app folder . Which i am using for build configurations in build.gradle . I need to read this file in java code . But i can figure out the path should i use . How can i read this file in java code . code below gives me FileNotFoundException try { Properties properties = new Properties(); File inputStream=new File("/config.properties"); properties.load(new FileInputStream(inputStream)); return properties.getProperty("BASE_URL"); }catch