こちらを参考させていただきました。

@Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        if(v == btnFileOpen ) {

        	FileListDialog dialog = new FileListDialog(this);
        	dialog.setDirectorySelect(false);
        	dialog.setOnFileListDialogListener(new onFileListDialogListener() {
        		@Override
        		public void onClickFileList(File file) {
        			if(file == null){
        				//not select
        			}else{
        				//select file or directory
        				//TextView txtinput = (TextView) findViewById( R.id.input_text_id);
        				//txtinput.setText( file.getPath() );
        				readToFile( file.getPath() ) ;
        			}
        		}
        	});
        	dialog.show("/", "select");
        }
    }

コマンドプロンプトより

PC->Android
adb push sample.txt /sdcard/

Android->PC
adb pull /sdcard/sample.wav

	public void readToFile( String fileName ) {
		// String fileName = Environment.getExternalStorageDirectory()
		//		+ "/sample.txt";

		FileInputStream fis = null;

		try {
			TextView txtinput = (TextView) findViewById( R.id.input_text_id);
			fis = new FileInputStream(fileName);

			byte[] readBytes = new byte[fis.available()];
			fis.read(readBytes);
			String readString  = new String(readBytes);

			txtinput.setText( readString );
			Log.v("readString", readString);
		} catch (FileNotFoundException ex) {
			ex.printStackTrace();
		} catch (IOException ex) {
			ex.printStackTrace();
		}
	}
© 2024 Falco Tech Blog Suffusion theme by Sayontan Sinha