android-sdcard

Loading Images from SD card to ViewPager Android

我怕爱的太早我们不能终老 提交于 2019-12-12 00:32:30
问题 I need to Load Images from a folder in SD Card into a ViewPager. This is what i have managed so far. public Drawable getImageFromSdCard(String imageName) { Drawable d = null; try { String path = Environment.getExternalStorageDirectory().toString() + "/YourSubDirectory/"; Bitmap bitmap = BitmapFactory.decodeFile(path + "/" + imageName + ".png"); d = new BitmapDrawable(bitmap); } catch (IllegalArgumentException e) { // TODO: handle exception } return d; } How can i set this as a ViewPager ? 回答1

Android, folder deleted after some time

老子叫甜甜 提交于 2019-12-11 19:22:44
问题 My app is creating a folder and then an xml file on the sdcard. But after some time the folder is deleted and the file with it. The file is used to store a backup of the data from the app. I dont need something new to make backup but a description of why it happens. The folder is created in the root of the sdcard with the name 'backup'. This is how I create the folder and file: File path = new File(Environment.getExternalStorageDirectory() + "/backup/tet/"); path.mkdirs(); File backupdir =

copy images from assest to sd card on install android application

[亡魂溺海] 提交于 2019-12-11 17:50:50
问题 i have some images should be displayed in the Application, the Q. is how to copy the images i am putting in the assets folder in the code to a folder under the SC card of the user on install the application on the phone 回答1: Try with this, private void copyAssets() { AssetManager assetManager = getAssets(); String[] files = null; try { files = assetManager.list(""); } catch (IOException e) { Log.e("tag", e.getMessage()); } for(String filename : files) { InputStream in = null; OutputStream out

store image to SD card

左心房为你撑大大i 提交于 2019-12-11 15:26:10
问题 i'm using cropping functionality in my android application and it works fine but i want to save cropped image to my SD Card . For that what steps needs to be followed? 回答1: If the Bitmap you cropped is called yourBitmap File sdcard = Environment.getExternalStorageDirectory(); File f = new File (sdcard, "filename.png"); FileOutputStream out = new FileOutputStream(f); yourBitmap.compress(Bitmap.CompressFormat.PNG, 90, out) 回答2: Try this : public void saveBitmap(Bitmap bmp) { String file_path =

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

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 move a file from sdcard to app data folder?

和自甴很熟 提交于 2019-12-11 12:46:44
问题 In my app I need to move files from the sdcard to /data/data/com.pack.main/ folder.The code I am using is this: ContextWrapper cw = new ContextWrapper(getApplicationContext()); File directory = cw.getDir("/data/data/com.cuelearn.main/", Context.MODE_PRIVATE); File mypath=new File(directory,object.VIDEO_FILENAME+".mp4"); copyFile(new File(Environment.getExternalStorageDirectory(),"/cue_learn_data/video_files/"+object.VIDEO_FILENAME+".mp4"),mypath); and the copyFile() method is: public static

An error occured while executing doInBackground()

柔情痞子 提交于 2019-12-11 12:03:38
问题 I am using a doInBackground() method to save my database as a xml file and back up the database. it backs up the database and saves it but force closes when trying to save into xml file. ON CLICK AND SAVE/EXPORT @Override public void onClick(View v) { case R.id.clockOut: /*if (WWActivity.this.isExternalStorageAvail()) { new ExportDatabaseFileTask().execute(); } else { Toast.makeText(WWActivity.this, "External storage is not available, unable to export data.", Toast.LENGTH_SHORT).show(); }*/

Recorded audio Using AndroidRecord API fails to play

霸气de小男生 提交于 2019-12-11 08:39:46
问题 Am developing an android app that has the feature to record the user speech. For this I have used the AndroidRecord Audio API. Currently the pcm file(recorded audio file - recordedAudio.pcm) getting generated successfully in the sd card. But am not able to play that file. I tried in PC also with windows media palyer and some other players. But nothing helps. Following are my code snippet . private int minBufSize; private AudioRecord recorder; private int sampleRate = 44100; private int

Has SD card writing been blocked?

无人久伴 提交于 2019-12-11 07:26:02
问题 I am trying to provide a functionality in my app that the media or storage files used in my application can be moved to SD card by the user. I am trying to use the code as described in below link http://www.java-samples.com/showtutorial.php?tutorialid=1523 But I get a permission exception. When I searched for getting that permission, I see that I have to root the device. I don't want to root my device, as it is illegal, no? Is there any android device model that comes rooted from the