android-file

displaying album art for music using picasso

一笑奈何 提交于 2019-12-11 08:26:49
问题 Hello I need to display album art for music files efficiently using Picasso . I already configured picasso in my app. But I am not able to display album art from internal storage for music files. I tried this code but it's not working means no error but it doesn't display anything. Using uri : cursor = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, MediaStore.Audio.AudioColumns.DURATION + ">0", null, sortOrder); cursor.moveToFirst(); a = cursor.getString(cursor

What is the right point in my code to rotate an landscape image captured in my app?

人走茶凉 提交于 2019-12-11 07:37:17
问题 I don't have much experience working with the camera and files in general. I've integrated CameraKit's library to capture images, and this is my current code: captureButton.setOnClickListener { cameraKitView.captureImage() { _, p1 -> val timeStamp = System.currentTimeMillis().toString() val fileName = "Dere$timeStamp.jpg" val path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString() + File.separator + "Dere" val outputDir = File(path) outputDir.mkdir()

How to read file names from Internal storage in Android

大兔子大兔子 提交于 2019-12-11 04:27:31
问题 I want to read the file names from the default internal storage folder of my app but even if there are some files I get a List of size 0 I use the following to read the file names File dirFiles = Settings.this.getFilesDir(); File list[] = dirFiles.listFiles(); for( int i=0; i< list.length; i++) { myList.add( list[i].getName() ); } What I am doing wrong here? is the path I get correct? or it needs to have a "/" at the end of it? /data/data/com.compfrind.contacts/files 回答1: Try this way private

How to get the file path for the picked files from the external storage in android?

£可爱£侵袭症+ 提交于 2019-12-11 02:23:52
问题 I am facing the issues in picking the file path of the file, i searched for all over the stack overflow but the issue is not solved .Code for picking the files from the device is shown below. Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); //intent.addFlags(ST) startActivityForResult(Intent.createChooser(intent, "Choose File to Upload.."), PICK_FILE_REQUEST); The picked files from intent are get by protected

Android DownloadManager save to Download folder

﹥>﹥吖頭↗ 提交于 2019-12-10 23:51:16
问题 I'm using DownloadManager to download file, I wanted to put the downloads in the standard download folder so people could easily find them using file manager looking in the most obvious place: Uri downloadLocation = Uri.fromFile(new File(Environment.DIRECTORY_DOWNLOADS, filename)); request.setDestinationUri(downloadLocation); Long reference = downloadManager.enqueue(request); But I get an exception because that isn't an external drive. Is there no way to download a file to the user's download

new File(path) always actually creates a file on android?

孤者浪人 提交于 2019-12-10 10:13:58
问题 I am trying to check if a file exits on android sd card...so i do: File f=new File(sdpath + "/" + DATABASE_NAME); // if(!f.exits()) { ...create new file.. } else { ...do something... } Every time this actually creates the directory or file on the sd card. I know it doesnt exist, and when the new File is executed it is created and it shouldnt ? I read all across google that new File doesnt create an actual file on the file system , but in my case it does... Any alternatives to checking if a

how can I delete line from txt?

倾然丶 夕夏残阳落幕 提交于 2019-12-09 22:58:54
问题 I mean , I want to delete line from my text on android. How can I delete? I do not want to read one txt and create another with removing line. I want to delete line from my existing txt. thanks. 回答1: This is a pretty tricky problem, despite it looking a trivial one. In case of variable lines length, maybe your only option is reading the file line by line to indentify offset and length of the target line. Then copying the following portion of the file starting at offset , eventually truncating

Missing android.support.FILE_PROVIDER_PATHS meta-data

こ雲淡風輕ζ 提交于 2019-12-08 22:02:48
问题 I am trying to open the pdf file which I downloaded & saved in external storage. But When I open my app its gets crashed and showing following error; 08-31 00:58:31.304 1807-1807/? E/AndroidRuntime: FATAL EXCEPTION: main Process: medimanage.corporate.mobile, PID: 1807 java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data at android.app.ActivityThread.installProvider

getExternalFilesdir Fail

ε祈祈猫儿з 提交于 2019-12-08 17:23:03
问题 OnActivityCreated I'm doing: activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES); In logcat I get: com.package W/ContextImpl﹕ Failed to ensure directory: /storage/sdcard1/Android/data/com.package/files/Pictures This happens only on LOLLIPOP (MOTO G 2014), and everything is fine on KITKAT (Nexus 4). I've WRITE_EXTERNAL_STORAGE on manifest. What am I missing here? The storage is mounted and reachable via a file browsing app (like ES Explorer). EDIT: Surprisingly the file is correctly

save audio file in raw or assets folder to sdcard android

ⅰ亾dé卋堺 提交于 2019-12-08 12:16:10
问题 Hi guys i am having a audio file in assets folder and i need to save the same file onto sdcard . How to acheive this. Below is the code i am using to save file String filename = "filename.txt"; File file = new File(Environment.getExternalStorageDirectory(), filename); FileOutputStream fos; byte[] data = new String("data to write to file").getBytes(); try { fos = new FileOutputStream(file); fos.write(data); fos.flush(); fos.close(); } catch (FileNotFoundException e) { // handle exception }