↓で、できるかと思ったら、できなかった…orz
File file.renameTo( File newPath );
じゃ、InputStream で読み込んで、OutputStream で書き出して、読み込んで書き出して…
と、ループしなきゃならないのか。
それは面倒…。
なんて思ってたら、FileChannel を使うとよいらしい。
下記、例では、アプリのプリファレンスをSDへコピーしている。
public void cpTo_sd( ) {
File file = new File( Environment.getDataDirectory().getPath()+"/data/"
+ this.getPackageName()
+"/shared_prefs/pref.xml" );
File cpFile = new File( Environment.getExternalStorageDirectory().getPath()
+"/pref.xml" );
try{
FileChannel channel_In = new FileInputStream( file ).getChannel();
FileChannel channel_Out = new FileOutputStream( cpFile ).getChannel();
channel_In.transferTo( 0, channel_In.size(), channel_Out );
channel_In.close();
channel_Out.close();
}catch( Exception ex ){
Log.d( "TEST", "->sd : copy error..." );
}
//--
}
FileChannel には、他にもlock や読み込み位置の指定などがあり、色々と使えそうである。
http://developer.android.com/reference/java/nio/channels/FileChannel.html


![著作権フリー背景素材集[家]](http://img.dlsite.jp/modpub/images2/work/doujin/RJ089000/RJ088095_img_mini.jpg)





migimaki.com











![著作権フリー背景素材集[家]](http://img.dlsite.jp/modpub/images2/work/doujin/RJ089000/RJ088095_img_sam.jpg)
右巻きソフトウェア
