android-file

How to access /storage/emulated/0/

谁说我不能喝 提交于 2019-12-02 17:31:49
I have written a code to record audio and save it to below file location. private String getFilename() { String filepath = Environment.getExternalStorageDirectory().getPath(); File file = new File(filepath, AUDIO_RECORDER_FOLDER); if (!file.exists()) { file.mkdirs(); } return (file.getAbsolutePath() + "/" + System.currentTimeMillis() + file_exts[currentFormat]); } In Logcat, it gives me a file location as /storage/emulated/0/AudioRecorder/1436854479696.mp4 I am not able to find this file location on my SD card. How to access the location? As Hiren stated, you'll need a file explorer to see

Database won't remove when uninstall the Android Application

五迷三道 提交于 2019-12-02 17:25:43
I have two major questions. Database won't delete when uninstall app. Downloaded files won't delete while unstable the app. There is a database in my android application. I create it by java class as follows. public DataBaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } public DataBaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) { super(context, name, factory, version, errorHandler); } @Override public void onCreate(SQLiteDatabase db) { // creating required tables db.execSQL(CREATE

How to pass attachment from file browser and camera in a custom mail sender

梦想的初衷 提交于 2019-12-02 16:07:56
问题 I have used a tutorial to implement a custom email sender, now I have this code try { m.addAttachment("/sdcard/filelocation"); if(m.send()) { Toast.makeText(Comunic.this, "Ok", Toast.LENGTH_LONG).show(); } else { Toast.makeText(Comunic.this, "Error.", Toast.LENGTH_LONG).show(); } } catch(Exception e) { Toast.makeText(Comunic.this, "Error.", Toast.LENGTH_LONG).show(); } And need to pass in m.addAttachment("/sdcard/filelocation"); a file selected from the file browser or a photo(according the

Android getAbsolutePath() not returning full path

∥☆過路亽.° 提交于 2019-12-02 12:31:16
问题 I create a file and save an image to it using the following code: private File createImageFile() throws IOException { String timeStamp = new SimpleDateFormat("yyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = getActivity().getApplicationContext().getFilesDir(); File image = File.createTempFile(imageFileName, ".jpg", storageDir); return image; } When I use image.getAbsolutePath(); , I get somwthing like this: /data/data/co.za.package.app

Make a txt file in internal storage in android

霸气de小男生 提交于 2019-12-02 12:02:20
问题 i want to make one folder on root and put txt file and append data ' My java code public void generateNoteOnSD(String sFileName, String sBody){ try { String fileName = "error"; String headings = "Hello, world!"; String path = "/data/root/"; File file = new File(path, fileName+".txt"); if (!file.exists()) { file.mkdirs(); } File gpxfile = new File(file, sFileName); FileWriter writer = new FileWriter(gpxfile); writer.append(sBody); writer.flush(); writer.close(); // Toast.makeText(this, "Saved"

how to save capture image in sdcard?

跟風遠走 提交于 2019-12-02 09:39:56
I want to use default camera and capture image. i want save image in sdcard/photofolder/ and save filename as curenttime format in sdcard/photofolder/ also display capture image in imageview page Uri outputFileUri = Uri.fromFile("/sdcard/Photofolder/"); Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(intent, CAMERA_REQUEST); protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAMERA_REQUEST) { Bitmap photo = (Bitmap) data.getExtras().get(

Make a txt file in internal storage in android

时光总嘲笑我的痴心妄想 提交于 2019-12-02 04:38:34
i want to make one folder on root and put txt file and append data ' My java code public void generateNoteOnSD(String sFileName, String sBody){ try { String fileName = "error"; String headings = "Hello, world!"; String path = "/data/root/"; File file = new File(path, fileName+".txt"); if (!file.exists()) { file.mkdirs(); } File gpxfile = new File(file, sFileName); FileWriter writer = new FileWriter(gpxfile); writer.append(sBody); writer.flush(); writer.close(); // Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show(); } catch(IOException e) { Log.d("file error", ""+e.getMessage()); } } I am

Android getAbsolutePath() not returning full path

被刻印的时光 ゝ 提交于 2019-12-02 04:26:58
I create a file and save an image to it using the following code: private File createImageFile() throws IOException { String timeStamp = new SimpleDateFormat("yyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = getActivity().getApplicationContext().getFilesDir(); File image = File.createTempFile(imageFileName, ".jpg", storageDir); return image; } When I use image.getAbsolutePath(); , I get somwthing like this: /data/data/co.za.package.app/files/filename.jpg The actual path of the image is: /storage/sdcard0/Android/data/co.za.package.app/files

Unable to write files in Android P

不羁岁月 提交于 2019-12-02 02:26:25
问题 I couldn’t write files in Android P Memory Card. The same code is working fine in Android O. new File(file.getParent()).mkdirs(); output = new ObjectOutputStream(new FileOutputStream(file)); output.writeObject(obj); I am able to read the files from the same device(Memory Card), but when I try to write the file, it is throwing Permission Denied exception. Initially it was throwing me No such file or Directory , but after giving root permissions, it is throwing Permission Deniod exception. Note

Unable to write files in Android P

谁说胖子不能爱 提交于 2019-12-01 22:26:10
I couldn’t write files in Android P Memory Card. The same code is working fine in Android O. new File(file.getParent()).mkdirs(); output = new ObjectOutputStream(new FileOutputStream(file)); output.writeObject(obj); I am able to read the files from the same device(Memory Card), but when I try to write the file, it is throwing Permission Denied exception. Initially it was throwing me No such file or Directory , but after giving root permissions, it is throwing Permission Deniod exception. Note: My app is system privileged app and also I have given the Devicewith root permission by adb root,