sd-card

setReadOnly not working

泪湿孤枕 提交于 2019-12-10 18:13:53
问题 I am using setReadOnly method to make my app's directory stored on my SD card 'Read-only'. However this method when called is returning 'false' even though I have provided the app with android.permission.WRITE_EXTERNAL_STORAGE permission in the manifest. Here's my code : is.close(); fos.close(); Decompress d = new Decompress(productDirectory + "/downloadedfile.zip", productDirectory + "/unzipped/"); d.unzip(); File zipfile = new File(productDirectory + "/downloadedfile.zip"); zipfile.delete()

file.canWrite() says “true” but I can't write on removable storage (kit kat)

核能气质少年 提交于 2019-12-10 16:36:39
问题 I recieve a intent from camera with a photo taken in this path: /storage/extSdCard/DCIM/Camera/photoCaptured.jpg And I want to resize (already does) of the image and overwrite in the same path... I can do it on 2.3, 4.1 and 4.3, but... not in 4.4 so... maybe the problem is the permission on this folder, so I check with this... if( myFile.canWrite() ){ Log.e("myMethodToSave", "you have permission: " + myFile); } else { Log.e("myMethodToSave", "forget it!: " + myFile); } ...and I have

TMS320F2812 FatFs f_write returns FR_DISK_ERR

谁说我不能喝 提交于 2019-12-10 16:36:27
问题 I have problem with an SD card. I'm using the FatFs library ver R0.10b to access the SD card. My code: // .... // FATFS fatfs; FIL plik; FRESULT fresult,res1,res2,res3,res4,res5; UINT zapisanych_bajtow = 0 , br; UINT zapianie_bajtow = 0; char * buffor = "123456789abcdef\r\n"; unsigned short int i; void main(void) { // ... // res1 = f_mount(0,&fatfs); // returns FA_OK res2 = f_open( &plik, "f721.txt", FA_OPEN_ALWAYS | FA_WRITE ); // returns FA_OK if( res2 == FR_OK ) { res3 = f_write( &plik, (

uploading docx,doc and pdf file to sharepoint online from native android app

亡梦爱人 提交于 2019-12-09 19:40:50
问题 I am developing an android app to remotely access sharepoint online.I am able to upload files using http put method and view them but i am not able to open them.I feel i am not specifying the proper content type.Here's my code: try { File sdcard = Environment.getExternalStorageDirectory(); //Get the text file File file = new File(sdcard, "gps.doc"); FileInputStream fIn = new FileInputStream(file); BufferedReader myReader = new BufferedReader( new InputStreamReader(fIn)); String aDataRow = "";

Android open or create database

送分小仙女□ 提交于 2019-12-09 13:21:11
问题 I am trying to create a database on my sd card. Whenever I call SQLiteDatabase.openOrCreateDatabase I get the error: 07-21 13:33:17.587: ERROR/AndroidRuntime(5541): Caused by: android.database.sqlite.SQLiteException: unable to open database file Does anyone know what may be causing this? Here is the code I have in the open() method of my database class: File sdcard = Environment.getExternalStorageDirectory(); String dbfile = sdcard.getAbsolutePath() + File.separator+ "external_sd" + File

Some Android devices treat Internal Storage as SD Cards and External Storage as EXTSD

被刻印的时光 ゝ 提交于 2019-12-09 09:02:14
问题 I have a bunch of Android devices from different vendors. Some of them attach /mnt/sdcard to internal storage and /mnt/extsd to external storage(Scenario 1) and others attach /mnt/sdcard to external storage(Scenario 2) I think the second scenario is standard since the Android API provides a handle to this path. Now the problem is that in scenario 1, /mnt/extsd becomes readonly even with WRITE_EXTERNAL_STORAGE permission! This means I can only read data from the actual external sd card and not

Android: How to search files on sd card?

落爺英雄遲暮 提交于 2019-12-09 03:48:39
问题 How can I search files on my sd-card given an entered string? I'd like to search for "test" and want to get a list with all files that contain in the name the string "test": testfile.txt filetest.jpg thisisatestfile.xml etc. 回答1: You can use ListFiles() of Apache Commons IO, passing a RegexFileFilter FileFilter. Example using Commons IO jar library in your Android project : Collection<File> files = FileUtils.listFiles( Environment.getExternalStorageDirectory(), new RegexFileFilter(".*test.*")

accessing file on sdcard android

北慕城南 提交于 2019-12-08 18:49:33
I am new to Android development. I am trying to use the following code to email a file on my motorola milestone through gmail. Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType("audio/mp3"); sendIntent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/king1.mp3"); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject"); sendIntent.putExtra(Intent.EXTRA_TEXT, "this is the email content2"); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/king1.mp3")); startActivity(Intent.createChooser(sendIntent, "Title:")); Running the code sends the email but the attachment

Unable to retrieve data from SQLite DB on SD Card on WP8

久未见 提交于 2019-12-08 18:24:26
问题 I've created a SQLite DB using System.Data.SQLite in a console app. I've then moved this to the Windows Phone's SD card. I followed these instructions to add SQLite support to my WP8 app: https://github.com/peterhuene/sqlite-net-wp8 I locate the DB file and open it like so: ExternalStorageFile file = null; IEnumerable<ExternalStorageDevice> storageDevices = await ExternalStorage.GetExternalStorageDevicesAsync(); foreach (ExternalStorageDevice storageDevice in storageDevices) { try { file =

Create database from prestored db file on SDcard

↘锁芯ラ 提交于 2019-12-08 11:03:45
问题 The database i want to import is over 5Mb. When i put the .db in asset folder i got some errors. So i split the database into smaller db files and assemble the pieces to create the database. So is there any way i can import the database from sdcard and start using the db without splitting and assembling? Thanks in advance. 回答1: Yes, there is: place the database file inside the sdcard then create a method inside a class, the method is like: public class DB_Path { public final SQLiteDatabase