Where is my files?

Put your problem here if it does not fit any of the other categories.

Where is my files?

Postby NeoLiu » Mon Jan 07, 2008 6:26 am

Hi all

i want save a bitmap file. In the code no have throw any exception, but i can't find my file :cry:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         File file = null;
  2.  
  3.         OutputStream os = null;
  4.  
  5.                 try {
  6.  
  7.                         file = context.getFileStreamPath("X").getParentFile();
  8.  
  9.                 } catch (FileNotFoundException e1) {
  10.  
  11.                         // TODO Auto-generated catch block
  12.  
  13.                         e1.printStackTrace();
  14.  
  15.                 }
  16.  
  17.         //(file = /data/data/com.google.android.pic/file/xxx.png)      
  18.  
  19.         file = new File(file,"xxx.png");
  20.  
  21.         try {
  22.  
  23.                         os = context.openFileOutput(file.getName(), 0);
  24.  
  25.                 } catch (FileNotFoundException e) {
  26.  
  27.                         // TODO Auto-generated catch block <img src="http://www.anddev.org/images/smilies/icon_cry.gif" alt=":cry:" title="Crying or Very sad" />
  28.  
  29.                         e.printStackTrace();
  30.  
  31.                 }
  32.  
  33.                
  34.  
  35.                 mBitmap.compress(Bitmap.CompressFormat.PNG, 100, os);
  36.  
  37.  
  38.  
  39.         try {
  40.  
  41.                         os.close();
  42.  
  43.                 } catch (IOException e) {
  44.  
  45.                         // TODO Auto-generated catch block
  46.  
  47.                         e.printStackTrace();
  48.  
  49.                 }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
:cry: :cry: :cry: :evil: :evil: :evil: :evil: :evil:
NeoLiu
Junior Developer
Junior Developer
 
Posts: 17
Joined: Mon Jan 07, 2008 3:27 am

Top

Postby plusminus » Mon Jan 07, 2008 4:41 pm

Hello NeoLiu,

have a look at :src: this tutorial.

Code like this is enough to get the FileOutputStream (no need for getFileStreamPath("X").getParentFile()-Stuff):
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. FileOutputStream fOut = openFileOutput("xxx.png", MODE_WORLD_READABLE);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 19 guests