internal-storage

How to rename a file in internal Storage?

心已入冬 提交于 2021-02-10 08:02:01
问题 I have an image that I got from the user's album and I saved it in a folder. here is the code: filename = "pippo.png"; try { ContextWrapper cw = new ContextWrapper(getApplicationContext()); File directory = cw.getDir("imageDir", Context.MODE_PRIVATE); // Create imageDir File myPath = new File(directory,filename); FileOutputStream out = new FileOutputStream(myPath); theImage.compress(Bitmap.CompressFormat.PNG, 90, out); out.flush(); out.close(); Log.d("Image","saved success"); picture =

How to rename a file in internal Storage?

丶灬走出姿态 提交于 2021-02-10 08:01:56
问题 I have an image that I got from the user's album and I saved it in a folder. here is the code: filename = "pippo.png"; try { ContextWrapper cw = new ContextWrapper(getApplicationContext()); File directory = cw.getDir("imageDir", Context.MODE_PRIVATE); // Create imageDir File myPath = new File(directory,filename); FileOutputStream out = new FileOutputStream(myPath); theImage.compress(Bitmap.CompressFormat.PNG, 90, out); out.flush(); out.close(); Log.d("Image","saved success"); picture =

Error when downloading a file with url into internal storage Android Studio

戏子无情 提交于 2021-01-29 18:23:06
问题 I'm trying to download a mp3 music into internal storage, but conexion.connect(); seems like it have a error and end up going to the Exception. Here is my code: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { String filePath = getExternalCacheDir().getAbsolutePath(); filePath += "/audiotest.mp3"; int count; try { URL url = new URL("my_url_to_download"); URLConnection conexion = url.openConnection(); conexion.connect(); /

How to save an audio file in internal storage android

China☆狼群 提交于 2020-01-06 17:09:46
问题 I was wondering how can I save an audio file in the Internal storage of my android device. Specifically I would like my app that records sound from the microphone to save this file in the internal storage. I know that for external storage there is something like: outputFile = Environment.getExternalStorageDirectory()+"/myrecord.3gpp"; Is there anything similar for internal storage also? Thanks! 回答1: Use getFilesDir() SDCardpath = getFilesDir(); myDataPath = new File(SDCardpath.getAbsolutePath

How to save an audio file in internal storage android

荒凉一梦 提交于 2020-01-06 17:09:25
问题 I was wondering how can I save an audio file in the Internal storage of my android device. Specifically I would like my app that records sound from the microphone to save this file in the internal storage. I know that for external storage there is something like: outputFile = Environment.getExternalStorageDirectory()+"/myrecord.3gpp"; Is there anything similar for internal storage also? Thanks! 回答1: Use getFilesDir() SDCardpath = getFilesDir(); myDataPath = new File(SDCardpath.getAbsolutePath

Saving an image from ImageView into internal storage

别等时光非礼了梦想. 提交于 2020-01-01 19:56:46
问题 I have created an ImageView and I can see the preview of the Camera and load the captured image into the ImageView and I wanted to store the image into a directory in my internal memory. I have referred many posts and tried but I couldn't find my image in my internal memory. This is the code I have used: package com.example.shravan.camera; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; import android.content.pm.PackageManager; import

How can I write a file to a folder of the internal storage on Android?

北慕城南 提交于 2019-12-23 09:38:21
问题 I have written a method which creates a file and writes data to the file and stores in the internal storage. When I get the absolute path or path of the file [I have added log messages to experiment with the operations on the File], it shows me that the file is getting created under the root directory and its under the /data/data/mypackagename/files/filename.txt. Nevertheless, I could find these folders on the DDMS where I could find the file which has been created by the method which I have

Listing files in “/sdcard/” returns null?

こ雲淡風輕ζ 提交于 2019-12-13 07:24:15
问题 I have an app that needs access to an android phone's internal storage, such as the Download folder. However when I try to list the files it alimport java.io.File; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class Main extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); File root = new File("/"); // Works File mnt = new File("/mnt/"); // Works File mnt2 =

Android: Save two Bitmaps with same name in internal storage

送分小仙女□ 提交于 2019-12-12 02:03:40
问题 If I save a Bitmap called "picture.jpg" in internal storage and some steps later I save another Bitmap called "picture.jpg" too, what happens then? Does the second Bitmap overwrite the first or are there two Bitmaps with the same name then? 回答1: It will show you an error, I suggest you could use a dynamic file name or delete it before saving, in the case of dynamic, you could use something like this: static int fCount = 0; File file = new File(Environment.getExternalStorageDirectory() + File

Android Xamarin: Open file from Storage (with path)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 02:32:59
问题 My app loads different types of files from my server to the device storage. For all my files i want to open, i have the path of the files in the storage. For .pdf -Files I am using a WebView which opens the .pdf -Files at the given path (for example) Therefore I split the path var fileType = path.Split('.').Last().ToLower(); and if the fileType is pdf , I open the WebView. For .docx , .xlsx , etc. files, I want my app to ask me, what program I want to use to open the file. I do not want to