Android touchpaint API
我正在玩touchpaint api,我想知道是否有人可以指出一些可以将绘图保存到sd卡的代码。来自Android SDK示例中的sensors/src/aexp/sensors/SensorMonitor.java: 以下是创建文件的方式:Android touchpaint API,android,Android,我正在玩touchpaint api,我想知道是否有人可以指出一些可以将绘图保存到sd卡的代码。来自Android SDK示例中的sensors/src/aexp/sensors/SensorMonitor.java: 以下是创建文件的方式: private PrintWriter captureFile; File captureFileName = new File( "/sdcard", "capture.csv" ); captureStateText
private PrintWriter captureFile;
File captureFileName = new File( "/sdcard", "capture.csv" );
captureStateText = "Capture: "+captureFileName.getAbsolutePath();
try {
captureFile = new PrintWriter( new FileWriter( captureFileName, false ) );
} catch( IOException ex ) {
Log.e( LOG_TAG, ex.getMessage(), ex );
captureStateText = "Capture: "+ex.getMessage();
}
if( captureFile != null ) {
for( int i = 0 ; i < sensorEvent.values.length ; ++i ) {
if( i > 0 )
captureFile.print( "," );
captureFile.print( Float.toString( sensorEvent.values[i] ) );
}
captureFile.println();
}
}
captureFile.close();
以下是写入文件的方式:
private PrintWriter captureFile;
File captureFileName = new File( "/sdcard", "capture.csv" );
captureStateText = "Capture: "+captureFileName.getAbsolutePath();
try {
captureFile = new PrintWriter( new FileWriter( captureFileName, false ) );
} catch( IOException ex ) {
Log.e( LOG_TAG, ex.getMessage(), ex );
captureStateText = "Capture: "+ex.getMessage();
}
if( captureFile != null ) {
for( int i = 0 ; i < sensorEvent.values.length ; ++i ) {
if( i > 0 )
captureFile.print( "," );
captureFile.print( Float.toString( sensorEvent.values[i] ) );
}
captureFile.println();
}
}
captureFile.close();