I loaded up the OpenCV library and demos into Eclipse and was able to run them without issues. I have since taken the tutorial 3 code (capture image, etc.) and modified it slightly to instead save an image with the same name every time in a specific location, where after I proceed to run some other OpenCV functions on this. This was working until a few days ago when I accidentally deleted the folder where this image was stored on my phone. My code checked to make sure the folder existed and if not then it created it before the photo was to be taken. Now though, the image never saves and there is no specific error in the logcat as to why. I will get a logcat posted in a few hours as I don't currently have my laptop with me. If anyone has any idea why this would occur please let me know. Thank You.
It is likely that you created the folder with some user or access permissions that do not allow your Android application to write on that folder. You need to research more about Android file system permissions...
Also make sure your Android application is allowed to read/write to the filesystem:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
You will find dozens of posts here on SO and elsewhere addressing these issues.
Related
First I have been searching for a solution for acouple of days now. It is very strange as the answer to my problem maybe very simple.
I am trying to make the simplest code to create sqlite database. there is plenty of examples in the web. the code does not generate any error and the application appears on the device. but when I try to locate the database in the specified location as in the title it does not seem to be created.
my specific questions
1-does the device has to be rooted to create a database file.
2-do I need special manualy entered permissions in the manifest file to create the database file.
3-Is there any prior settings that I have to do in android studio or a plug-in that I have to add.
4-Do I have to create the sub folders manualy because some devices dont even have the second data subdirectory of the main data directory in the main internal storage. Any way I created the folders and subfolders but no database appeared after running the application. I use a file explorer in the target device to inspect the existance of the database file.
many thanks for any attempts to help me as I seem to be stuck for few days now.
I found the files in the internal device memory using a root explorer.
The strange thing I have not seen any tutorial which alerts me to the hidden memory and root explorer. time wasted but along the way I learned many new things.
thanks all
I recently had to build an app which was pretty big (just under 180mb) mostly of stuff in the assets folder.
At one point I was running the application from eclipse and I got a strange error. I wish I recorded it but as far as I remember it was something along the lines of
Failed to launch application (null)
I was about to try install again when I realized the app had appeared on my phone. I ran it and everything was fine. Then I uninstalled it using adb uninstall.
I tried installing another app and it said I didn't have enough space. The available internal storage on my phone was around 250mb. Now it's 70mb. It looks like the previous application I ran is stuck somewhere in my phones internal storage even after I uninstalled. I had even set
android:installLocation="preferExternal"
The extra content doesn't seem to be accounted for anywhere. The application manager says my largest application is 12mb. Can't find anything strange in the DDMS file explorer.
Has anyone come across this kind of thing before? Is there some way of clearing out the internal storage? If I root my phone and go in to delete the file myself does anybody know where the file might be?
EDIT:
I did try the solution to 99% of problems - turning the phone off and on again.
Just in the event that this ever happens to another person, taking the battery out removed the unwanted data. I guess I should have thought of that sooner. So Blundells comment was mostly correct but didn't take in to account my pseudo-debility.
I am not a new developer to android. I have an application on the market. However, sometimes I get reported strange exceptions to have occured:
java.io.FileNotFoundException: res/drawable-mdpi/background.png
android.content.res.Resources$NotFoundException: File res/drawable-mdpi/background.png from drawable resource ID #0x7f02001f
This is by all means untrue because otherwise I wouldn;t have compiled or run the program myself. Also I am sure the resources are there. This is just one of the exception I have been reported. There are same exceptions for other resources mainly layouts.
So my question is how would this happen? Is it because the android system has failed installing correctly my app? I almost sure this must be the case because I have many users who use it without problem.
Please help regarding this.
There can be several possible reasons:
Moving application to SD card.
There was some problem in downloading or installing APK from market (file can be corrupted).
User get APK with corrupted file from other source (for example via bluetooth from other user)
Some system bug (from software, to brocken hardware)
Any way You can't do anything with this problem.
Could it be that the application was pushed to SD Card and something happens to the drawable while on SD. I saw similar issues with layouts rather drawable and it was because the application was pushed to SD.
Maybe you have included certain codes that reference content from Android SDK.
In my case, I faced similar issue and when I removed the line
android:background="?android:attr/actionBarItemBackground"
from my xml, everything works fine again.
How exactly does one go about such a simple thing in this beautifully over-complicated framework?
Yes I've read the documentation on Data Storage for Android, about 54.5 times. But I can not find anyplace where the documentation describes how you should go about placing files on the external storage at compile time.
Here's what I want to do: I want to include a couple of (big) (10-20mb) audio files in my application. Naturally, I do not want these to be stored on the internal storage, because they're just too big. So placing them in res/raw is not an option (because, if I understand correctly, things in res/raw will be placed in the internal storage of the phone, correct?)
The documentation only states that "if you want to store static files at compile time, use res/raw". Now if Android is smart enough to place those files on the external storage all by itself then I'm forever greatful.. But somehow I doubt that. All help is appreciated :)
(Sorry if it seems like I have an attitude, I've just spent way too much time on something so simple)
Thanks again :)
UPDATE: I ended up downloading the files from the application instead of including them at install-time. Thanks for the help guys!
I hit a problem while trying to download through a url, spent a lot of time trying to get it to work, and in the end the problem was because I hadn't declared the correct permission in the android manifest file! So to anyone who's looking to download stuff in their apps, do not forget to set the permissions in the android manifest, here are the permissions I needed:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
Place these above the start of the tag
If your large files are in the APK, they'll be stored wherever the APK gets stored - this can be internal or external, and it seems that this is not what you want. The most likely option for you seems to be to place the files on a web site and during the first run of your application, it must notice that the files do not exist and retrieve them post-installation.
how you should go about placing files on the external storage at compile time.
I'm assuming the above is a typo and you mean at install time.
As for your requirement - it's not possible to instruct the Android Application Manager to unpack different parts of an APK to different places during the installation.
Further to this, there's no guarantee that an APK download will go to the internal or external memory storage (where it will stay unless otherwise deleted).
And even further to this, there's no guarantee that even if a device has external storage, it will be available at installation time or have enough free space.
At this point I wonder about audio files which are 10-20MB in size - either they're very long (in duration) or they're encoded at a high bit-rate. If it's the latter then this doesn't make too much sense as most mobile devices have fairly poor audio reproduction (in relative terms)....just some thoughts to mull over.
I personally think mah's suggestion of downloading post-installation may be a better approach but my comments about availability of external storage still hold true.
Proper approach to solving your problem on Android is "don't put them with your application". Just download them on first start from your web server (using HTTP client API) or, if these files will be upgraded independently of the application itself, prepare them as a separate "application" for the user to download via Market.
I've done my fair share of searching for tutorials and guides online, but the only stuff I have found is from 2007 and out of date.
I wanted to know how to open a file from within my current application. For instance, if I click a "Browse" button, it will start another activity of a default file browser on the device (I don't have to implement my own, right?). Obviously I would need it to return the file so I could parse through it as I pleased.
I figured it would be some for of Intent binded to the the button, but I'm now sure.
Bad news - there is not a native "file selector". Good news - this guy made one so you don't have to.
Use Environment.getExternalStorageDirectory() instead of hard-coding the directory path to the SD card. There also seems to be a problem with getting the exact SD card directory using Android 3.0 and 3.1. I have a test app that reads and writes fine in Android 2.3.3 but the same piece of code doesn't work anymore (see https://stackoverflow.com/questions/6545478/android-3-1-sd-card-emulation).