| Author |
Message |
oladapo Freshman

Joined: 07 Jan 2008 Posts: 3 Location: Philadelphia
|
Posted: Sat Jan 12, 2008 12:49 am Post subject: |
|
|
I have the following error when I try to push a file to the data folder for my project...
| Java: | [2008-01-11 18:45:08] Failed to push the items
[2008-01-11 18:45:08] null |
What I am trying to do is figure out how I can display a photo taken from the Camera (like the photo in the CameraCapture tutorial). To get started I was going to put a source picture of something I know.
Anyone been successful in this? |
|
| Back to top |
|
 |
|
|
 |
plusminus Site Admin


Joined: 14 Nov 2007 Posts: 2660 Location: College Park, MD
|
Posted: Sat Jan 12, 2008 1:27 am Post subject: |
|
|
Hello oladapo,
that was a try from within eclipse, right
Here is your solution.
Regards,
plusminus _________________
Download my apps  Please remember, that this board is give & take 
| Android Development Community / Tutorials |
|
| Back to top |
|
 |
sasuke Experienced Developer

Joined: 30 Nov 2007 Posts: 57
|
Posted: Tue Jan 15, 2008 6:00 am Post subject: |
|
|
Hello all,
i got a FileNotFoundException when the program execute this :
| Java: |
FileOutputStream fOut = openFileOutput("/data/data/dj.android.CustomComponent/files/samplefile.txt",
MODE_WORLD_READABLE);
|
what's the prob?
Regards,
sasuke |
|
| Back to top |
|
 |
plusminus Site Admin


Joined: 14 Nov 2007 Posts: 2660 Location: College Park, MD
|
|
| Back to top |
|
 |
sasuke Experienced Developer

Joined: 30 Nov 2007 Posts: 57
|
|
| Back to top |
|
 |
plusminus Site Admin


Joined: 14 Nov 2007 Posts: 2660 Location: College Park, MD
|
|
| Back to top |
|
 |
|
|
 |
sasuke Experienced Developer

Joined: 30 Nov 2007 Posts: 57
|
Posted: Wed Jan 16, 2008 1:45 am Post subject: |
|
|
Hello plusminus,
it's works now.. after added the -wipe-data.
How to create the file not in our apps path (/data/data/package/files/) ?
Because as you say | plusminus wrote: | | he application runs with application privileges. I.e. the data folder requires system privileges. When you start adb you run as root. But this application runs only with application-privileges |
The file browser won't able to retreive the file in 'data' folder.
Regards,
sasuke |
|
| Back to top |
|
 |
cabernet1976 Senior Developer

Joined: 16 Nov 2007 Posts: 154 Location: China
|
Posted: Wed Jan 16, 2008 6:12 pm Post subject: |
|
|
I met a problem when I want to download a bitmap from web then write to SD card, it is failed, but write to /data/data/... with this tutorial is OK. The following is my code:
| Java: | private void testDownload(String urlStr) {
URL url = null;
try {
url = new URL(urlStr);
} catch (MalformedURLException e) {
Log.e(TAG, "error1:"+e.toString());
}
URLConnection conn = null;
try {
conn = url.openConnection();
} catch (IOException e) {
Log.e(TAG, "error2:"+e.toString());
}
try {
conn.connect();
} catch (IOException e) {
Log.e(TAG, "error2:"+e.toString());
}
InputStream is = null;
try {
is = conn.getInputStream();
} catch (IOException e) {
Log.e(TAG, "error3:"+e.toString());
}
BufferedInputStream bis = new BufferedInputStream(is);
Bitmap bm = BitmapFactory.decodeStream(bis);
File f = new File("/sdcard/1.jpg");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(f); // <--error here
} catch (FileNotFoundException e) {
Log.e(TAG, "error4:"+e.toString());
}
bm.compress(Bitmap.CompressFormat.JPEG, 100, fos);
try {
bis.close();
} catch (IOException e) {
Log.e(TAG, "error5:"+e.toString());
}
try {
is.close();
} catch (IOException e) {
Log.e(TAG, "error6:"+e.toString());
}
} |
After runing this method with a valid url, I got the error information:
error4:java.io.FileNotFoundException: /sdcard/1.jpg
I am sure the sdcard.img is fine, I can find a dir named "sdcard" in DDMS, and I have added '-sdcard D:\sdcard.img' in Emulator.
Could someone help me out?
Thanks.
-----added on Jan 22, 2008-----
Hi plusminus,
I read your reply just now. My code works fine after set the correct configuration of sdcard path.
Thanks. _________________ Upload2Flickr's blog: http://upload2flickr.blogspot.com
Last edited by cabernet1976 on Tue Jan 22, 2008 9:17 am; edited 1 time in total |
|
| Back to top |
|
 |
plusminus Site Admin


Joined: 14 Nov 2007 Posts: 2660 Location: College Park, MD
|
|
| Back to top |
|
 |
cabernet1976 Senior Developer

Joined: 16 Nov 2007 Posts: 154 Location: China
|
Posted: Thu Jan 17, 2008 2:23 am Post subject: |
|
|
Hello plusminus,
Thank you to reply me in your busy time.
I got your meaning, I will try to test whether SD Card is able to be wroten by FileWriter.
Thank you again. _________________ Upload2Flickr's blog: http://upload2flickr.blogspot.com |
|
| Back to top |
|
 |
cabernet1976 Senior Developer

Joined: 16 Nov 2007 Posts: 154 Location: China
|
Posted: Thu Jan 17, 2008 1:15 pm Post subject: |
|
|
I make a big mistake
The following is my lesson:
1. I created a sdcard, and put the sdcard.img in D:\dir1\sdcard.img
2. But I configured an invalid information to Eclipse Emulator as: -sdcard D:\sdcard.img. It is the origin of this issue.
I did the above two steps and went to bed the day before yesterday.
3. Yesterday, I opened my Android project, but found there is no 'sdcard' in DDMS file explore, but I didn't think it deeply.
4. I run 'adb push C:\test1.jpg /sdcard/test1.jpg', and checked DDMS file explore finding there was a sdcard directory now, and test1.jpg was in it. I think it maybe a bug of adb push, it deceive me.
Now you know the following story, I got FileNotFoundException, and it took me more than one hour. _________________ Upload2Flickr's blog: http://upload2flickr.blogspot.com |
|
| Back to top |
|
 |
plusminus Site Admin


Joined: 14 Nov 2007 Posts: 2660 Location: College Park, MD
|
Posted: Fri Jan 18, 2008 7:06 pm Post subject: |
|
|
Hello cabernet1976,
so you are fine now
By pushing that file probably a real folder was created, and not the (pseudo) sd-card.
Regards,
plusminus _________________
Download my apps  Please remember, that this board is give & take 
| Android Development Community / Tutorials |
|
| Back to top |
|
 |
tsdt Junior Developer

Joined: 09 Jan 2008 Posts: 12 Location: VIETNAM
|
Posted: Sat Jan 19, 2008 6:12 am Post subject: Re: read file |
|
|
| igal wrote: | When I write and read file in the same activity everything is OK.
But when I try to read file from another activity I get "File not found" error.
I do use MODE_WORLD_READABLE option when I write the file, and I do see the file:
"/data/data/com.myname.android/files/JScript.htm"
I use
| Java: | FileInputStream fIn = openFileInput("/data/data/com.myname.android/files/JScript.htm") |
statement.
Help, please, to find mistake.
Thanks in advance. |
I have the same problem too, Igal !!!.Hic,it takes me one day,but no thing resolved(FileNotFound Exception),even i used openFileInput("fileName"); and used "/data/data/.../files/data.txt".Please help me and Igal,i am in hurry for my demo of a apprentice. _________________ TSDT |
|
| Back to top |
|
 |
krystox Freshman

Joined: 22 Jan 2008 Posts: 7
|
Posted: Tue Jan 22, 2008 2:50 am Post subject: Re: Working with Files |
|
|
Hi,
Can someone help me with those problems I have?
How can I create a folder and write files into the folder?
For example: I want to create a file like /data/data/myapp/files/folder1/test.txt
I tried to use File class which has a mkdir() method. It can create a folder inside /tmp, but not other places, nor /data/data/myapp/files/
And I also tried to use openFileOutput("folder1/text.txt"), it returns FileNotFound exception as it can't include a file separator.
Anyone has an idea about this? |
|
| Back to top |
|
 |
cabernet1976 Senior Developer

Joined: 16 Nov 2007 Posts: 154 Location: China
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
© 2007, Android Development Community
All rights reserved.
Powered by phpBB.
|