2011-11-27 5 views
0

私はアンドロイドとプログラミングには初めてです。私はアンドロイドのタッチ塗料のAPIを使用して、図面を保存するために次のコードを使用していますが、明らかにファイルを開くことができなくても無駄です。アンドロイドでファイルを開く方法

誰かが私にそれのためのいくつかのコードを手伝ってくれるのだろうかと思っていました。

// Function saves image to file 
public String save(Bitmap mBitmap, boolean showMsg) { 
    String filename; 
    Date date = new Date(); 
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); 
    filename = sdf.format(date); 
    try { 

     String path = Environment.getExternalStorageDirectory().toString() + "/modTouchPaint/"; 
     File file1 = new File(path); 
     file1.mkdirs(); 

     OutputStream fOut = null; 
     File file = new File(path, filename + ".jpg"); 
     fOut = new FileOutputStream(file); 

     mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut); 
     fOut.flush(); 
     fOut.close(); 

     if (showMsg) 
      Toast.makeText(this, "Picture saved to " + path + filename + ".jpg", 9000).show(); 

     return path + filename + ".jpg"; 
    } catch (Exception e) { 
     e.printStackTrace(); 

     Toast.makeText(this, "Please make sure that SD card is installed", 5000).show(); 

     return null; 
    } 
} 

答えて

0
Bitmap bitmap = BitmapFactory.decodeFile(pathToFile); 

詳細についてはdocumentationを参照してください。

関連する問題