android-sdcard

android: how can get full path of a file stored in a folder in sdcard?

那年仲夏 提交于 2019-11-30 17:04:24
I am working in android. i want to get the full path of a file selected by user. my files are stored in sdcard. but may be in a folder in sd card. I have some folders in my sdcard. I want to get the full path of a file on which i click. Suppose I have an image peacock.png in folder image/birds. So the path is mnt/sdcard/image/birds/peacock.png Please suggest me how can i get the full path of a file. If you need my code which i am using for help then tell me i will send it here. Thank you in advance. Here's a code snippet from this tutorial, that shows the pick file Intent implementation:

Android backup and restore database to and from SD-card

喜你入骨 提交于 2019-11-30 14:48:45
I'm currently looking to build a backup feature in my Android application. However I'm kinda struggling before even starting to implement it because I'm not sure what the correct way to go is. I found some interesting articles on the net and so I came up with three possible solutions: Backup the entire DB file to the SD card Export the DB-data to an XML file on the SD card Use the Android backup mechanism to backup the entire DB to the Google cloud Now I was wondering what you guys think about these 3 solutions, or do you know another (maybe an even better way to go) and what is in your eyes

Android: remove an image from sd card

佐手、 提交于 2019-11-30 11:59:46
I need to remove an image from sd card chosen by user. In my Activity, after an user select an image from gallery, i execute this code: public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { if (requestCode == SELECT_PICTURE) { Utils.imgUri = data.getData(); Utils.imgPath = getPath(Utils.imgUri); File file = new File(Utils.imgPath); boolean deleted = file.delete(); } } } where getPath method is: public String getPath(Uri uri) { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = managedQuery(uri, projection, null, null,

Android - Saving a downloaded image from URL onto SD card

爱⌒轻易说出口 提交于 2019-11-30 07:32:30
I am loading an image from an URL on button click, and storing it as a Bitmap. Now i want to know how to save that downloaded image into sd card as well as in system. I attempted to do it the following way: package com.v3.thread.fetchImage; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.os

Do I have to declare both WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE?

江枫思渺然 提交于 2019-11-30 07:05:31
问题 Is it enough to declare <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> or do I also have to declare <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> ? The Javadocs omit this important information. 回答1: READ_EXTERNAL_STORAGE only exists as of Jelly Bean (Level 16). According to the docs, all applications as of Jelly Bean have that permission, even without declaring it: Provides protected read access to external storage. In Android 4.1 by

Android : Copy RawFile to Sdcard (video mp4)

元气小坏坏 提交于 2019-11-30 07:04:05
问题 What is wrong on this code ? I've a Raw file in my project (mp4 videofile), when i do this, and then i retreive file from SDcard file are not identical so video can not be load :( Do you have another way to automaticly copy a raw file to sdcard ? Thanks String FICHIER_BLOW = "blowvid4.mp4"; File f=new File(Environment.getExternalStorageDirectory(), FICHIER_BLOW); try { if (f.createNewFile()){ FileWriter ecrivain = new FileWriter(f); BufferedWriter bufEcrivain = new BufferedWriter(ecrivain);

How to get the Uri of a image stored on the SDCARD?

穿精又带淫゛_ 提交于 2019-11-30 03:23:47
问题 I need to get the URI of a image stored on the SDCARD. When i want to get the Uri of a image stored on drawable, i use this and it works perfect: i.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://" + getPackageName() + "/" + R.drawable.image)); But if i want to get the URI of a image stored on the SDCARD, i tryed with this, and it doesn't works, something is wrong: i.putExtra(Intent.EXTRA_STREAM, Uri.parse("/mnt/sdcard/car.jpg")); Please, can someone tell me how to get the correct

WARNING: File.mkdir() is ignored

江枫思渺然 提交于 2019-11-30 02:50:30
问题 I've created a basic Audio Recording App using Media Recorder API's. I'm trying to create a folder in the SD card and to save my recorded files to that folder. I'm getting this warning with following code. File.mkdir() is ignored // Assign random number to avoid audio file from overwriting Long tsLong = System.currentTimeMillis()/1000; // Specify a Location for the recorded file to be stored in the SD card mFileName = Environment.getExternalStorageDirectory().getAbsolutePath() + "

android: how can get full path of a file stored in a folder in sdcard?

為{幸葍}努か 提交于 2019-11-29 23:53:03
问题 I am working in android. i want to get the full path of a file selected by user. my files are stored in sdcard. but may be in a folder in sd card. I have some folders in my sdcard. I want to get the full path of a file on which i click. Suppose I have an image peacock.png in folder image/birds. So the path is mnt/sdcard/image/birds/peacock.png Please suggest me how can i get the full path of a file. If you need my code which i am using for help then tell me i will send it here. Thank you in

Delete copy of an image in sdcard

房东的猫 提交于 2019-11-29 17:16:07
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_height="wrap_content" android:text="Camera Test" /> <ImageView android:id="@+id/camera_image" android