android-sdcard

Android - How to receive the BOOT signal with an application installed on sdcard?

流过昼夜 提交于 2019-12-06 08:51:56
I need to start a notification service for an application when the device boots. I have implemented a BroadcastReceiver that listens to the boot signal in order to start the service. However, this works only if the application is not installed on sdcard (because the signal is received before the sdcard is mounted). Is there any solution to keep installing the application on sdcard and yet still receive that signal? Any hack for this? Let me know! Thanks! You could either: Register an account in the AccountManager and set up a sync service ( tutorial1 , tutorial2 ) -- Android will start your

Android ACTION_IMAGE_CAPTURE with EXTRA_OUTPUT in internal memory

☆樱花仙子☆ 提交于 2019-12-06 04:14:36
问题 When I'm taking a photo from a camera if I'm calling File file = new File(getFilesDir().getAbsolutePath() + "/myImage.jpg"); Uri outputFileUri = Uri.fromFile(file); cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); OK button on camera app is not functioning, simply does nothing (actually won't save it to internal memory I provided I guess and therefore the app itself does nothing). If I however call File

Failed to push selection: Read-only file system : while moving to SdCard

拜拜、爱过 提交于 2019-12-06 03:02:02
I have created a SDCard from my music player app. But when i add songs to the app it is showing error that [2013-01-23 16:09:18 - ddms] transfer error: Read-only file system [2013-01-23 16:09:18] Failed to push selection: Read-only file system I have set uses-permission in my Manifest <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> What might be wrong. Please help me out this issue. Go to sdk/platform-tools directory (to get access to the adb shell) then I typed the following commands: ./adb shell su mount -o rw,remount rootfs / chmod 777 /mnt/sdcard Then it works

Recommended path for caching images on external memory / sd card

情到浓时终转凉″ 提交于 2019-12-05 20:47:18
When I look at my sd card root directory in Android file transfer or Astro file manager it's a mess because apps are storing files all over the place. As developers we follow best practice by caching images/files etc to make our apps quicker and we use Environment.getExternalStorageDirectory() to get the root of the external storage (not hardcoding /sdcard). But what should go next? ideal world we'd follow a convention for dumping our cached files on the open field that is the external storage? Here's a couple of the options I see from my own device/experience: /.cache/app_name/ /.app_name/

Environment.getExternalStorageDirectory().getAbsolutePath() not working and giving /storage

倖福魔咒の 提交于 2019-12-05 18:25:58
My code myDb = openOrCreateDatabase("/sdcard/FashionGirl/ImagesDB.db", Context.MODE_PRIVATE, null); myDb = openOrCreateDatabase(dbPath, Context.MODE_PRIVATE, null); worked perfectly, but was giving warning Do not hardcode "/sdcard/"; use Environment.getExternalStorageDirectory().getPath() instead So I tried, String dbPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "FashionGirl/ImagesDB.db"; myDb = openOrCreateDatabase(dbPath, Context.MODE_PRIVATE, null); But strangely, its not working, where Environment.getExternalStorageDirectory().getAbsolutePath() has value /storage So

Android Adoptable Storage - get free Space

不打扰是莪最后的温柔 提交于 2019-12-05 16:46:15
I have a App that uses 3 kinds of storage: The internal storage, a external SD and if Version >= 6.0 a SD which is formatted as internal . I get the external SD path by using getExternalFilesDirs() , the internal Storage by getFilesDir() and the adopted (=internal) SD path by Environment.getExternalStorageDirectory() . Now, if I want to get the free Space, something like this: StatFs statFs = new StatFs(storageDir); long blocks = statFs.getAvailableBlocks(); return Formatter.formatFileSize(this, blocks * statFs.getBlockSize()); works for internal storage and external SD, but for adopted SD it

how to emulate a real external sd (update: removable storage) card in Android Emulator

橙三吉。 提交于 2019-12-05 12:24:01
I try to emulate a external sdcard as it would be in a real device. In a real device the external sdcard is not writeable except you use the new "Storage Access Framework" (API 21 & 22) When I add an sdcard either with a file or Size ... I always get a writeable sdcard, which is not true with a real device (I guess). I could create the Folder "CreateFolder" with just ( I know, I should not use the direct access, but this is only for a test to see if I have write access): String spathWriteTest="/storage/sdcard/"; new File(spathWriteTest + "createFolder").mkdir(); Any Idea, howto emulate a real

Android read/write permission of a folder

≯℡__Kan透↙ 提交于 2019-12-05 09:22:54
I am doing a new android app. I want to create a folder in "Android" folder which is available in sdcard. Before that I want to check whether the folder has read/write permission. How can I get that? can anyone help me to do this. You do it the old-school java way. Create a file object and call canWrite() and canRead() . File f = new File("path/to/dir/or/file"); if(f.canWrite()) { // hell yeah :) } To create a folder in Android folder the best way is: File path = getExternalFilesDir(); It will be your own directory so if you have permission for this, you will be able to read/write it if the

Unsupported virtual sd card in android emulator

本秂侑毒 提交于 2019-12-05 08:04:31
I don't know why the virtual SD card isn't working anymore. Someone got any leads or why could that happen? I'm using Android emulator with API 26 (Android O) To solve this problem use sd card size >= 512 MB in emulator . Android studio 2.3.3 created 100 MB sd card by default. The commit on the AOSP source code for Android Oreo states that a 512-megabyte file is created and mounted as a virtual disk for the system to use as an SD card. I faced the same problem too. Like others have mentioned, AVDs which have SD cards that are less than 512 MB do not detect the card after the upgrade to Android

Android sharing image doesn't work

馋奶兔 提交于 2019-12-05 06:47:24
I am trying to share a screenshot of the application using the following code: View content = findViewById(R.id.layoutHome); content.setDrawingCacheEnabled(true); Bitmap bitmap = content.getDrawingCache(); File sdCardDirectory = Environment.getExternalStorageDirectory(); File image = new File(sdCardDirectory,"temp.png"); // Encode the file as a PNG image. FileOutputStream outStream; try { outStream = new FileOutputStream(image); bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream); outStream.flush(); outStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch