YGPS/src/com/mediatek/ygps/YgpsActivity.java
private boolean createFileForSavingNMEALog() {
        Log.v("@M_" + TAG, "Enter startSavingNMEALog function");
        if (NMEALOG_SD) {
            if (!(Environment.getExternalStorageState()
                    .equals(Environment.MEDIA_MOUNTED))) {
                Log.v("@M_" + TAG, "saveNMEALog function: No SD card");
                Toast.makeText(this, R.string.no_sdcard, Toast.LENGTH_LONG)
                        .show();
                return false;
            }
        }

        String strTime = DATE_FORMAT
                .format(new Date(System.currentTimeMillis()));
        File file = null;
        if (NMEALOG_SD) {
            file = new File(Environment.getExternalStorageDirectory(),
                    NMEA_LOG_PREX + strTime + NMEA_LOG_SUFX);
        } else {
            File nmeaPath = new File(NMEALOG_PATH);
            if (!nmeaPath.exists()) {
                nmeaPath.mkdirs();
            }
            file = new File(nmeaPath, NMEA_LOG_PREX + strTime + NMEA_LOG_SUFX);
        }
        if (file != null) {
            try {
                file.createNewFile();
            } catch (IOException e) {
                Log.w("@M_" + TAG, "create new file failed!");
                Toast.makeText(this, R.string.toast_create_file_failed,
                        Toast.LENGTH_LONG).show();
                return false;
            }
        }
        try {
            mOutputNMEALog = new FileOutputStream(file);
        } catch (FileNotFoundException e1) {
            Log.w("@M_" + TAG, "output stream FileNotFoundException: "
                    + e1.getMessage());
            return false;
        }
        // set nmea hint
        mTVNMEAHint.setText((R.string.nmea_hint));
        return true;
    }
/**
     * Create file to record nmea log.
     *
     * @return True if create file success, or false
     */
Create file to record nmea log.
@return True if create file success, or false
Create file to record nmea log . @return True if create file success or false
private boolean createFileForSavingNMEALog() {
        Log.v("@M_" + TAG, "Enter startSavingNMEALog function");
        if (NMEALOG_SD) {
            if (!(Environment.getExternalStorageState()
                    .equals(Environment.MEDIA_MOUNTED))) {
                Log.v("@M_" + TAG, "saveNMEALog function: No SD card");
                Toast.makeText(this, R.string.no_sdcard, Toast.LENGTH_LONG)
                        .show();
                return false;
            }
        }
        String strTime = DATE_FORMAT
                .format(new Date(System.currentTimeMillis()));
        File file = null;
        if (NMEALOG_SD) {
            file = new File(Environment.getExternalStorageDirectory(),
                    NMEA_LOG_PREX + strTime + NMEA_LOG_SUFX);
        } else {
            File nmeaPath = new File(NMEALOG_PATH);
            if (!nmeaPath.exists()) {
                nmeaPath.mkdirs();
            }
            file = new File(nmeaPath, NMEA_LOG_PREX + strTime + NMEA_LOG_SUFX);
        }
        if (file != null) {
            try {
                file.createNewFile();
            } catch (IOException e) {
                Log.w("@M_" + TAG, "create new file failed!");
                Toast.makeText(this, R.string.toast_create_file_failed,
                        Toast.LENGTH_LONG).show();
                return false;
            }
        }
        try {
            mOutputNMEALog = new FileOutputStream(file);
        } catch (FileNotFoundException e1) {
            Log.w("@M_" + TAG, "output stream FileNotFoundException: "
                    + e1.getMessage());
            return false;
        }
        mTVNMEAHint.setText((R.string.nmea_hint));
        return true;
    }
private boolean createFileForSavingNMEALog ( ) { Log . v ( "@M_" + TAG , "Enter startSavingNMEALog function" ) ; if ( NMEALOG_SD ) { if ( ! ( Environment . getExternalStorageState ( ) . equals ( Environment . MEDIA_MOUNTED ) ) ) { Log . v ( "@M_" + TAG , "saveNMEALog function: No SD card" ) ; Toast . makeText ( this , R . string . no_sdcard , Toast . LENGTH_LONG ) . show ( ) ; return false ; } } String strTime = DATE_FORMAT . format ( new Date ( System . currentTimeMillis ( ) ) ) ; File file = null ; if ( NMEALOG_SD ) { file = new File ( Environment . getExternalStorageDirectory ( ) , NMEA_LOG_PREX + strTime + NMEA_LOG_SUFX ) ; } else { File nmeaPath = new File ( NMEALOG_PATH ) ; if ( ! nmeaPath . exists ( ) ) { nmeaPath . mkdirs ( ) ; } file = new File ( nmeaPath , NMEA_LOG_PREX + strTime + NMEA_LOG_SUFX ) ; } if ( file != null ) { try { file . createNewFile ( ) ; } catch ( IOException e ) { Log . w ( "@M_" + TAG , "create new file failed!" ) ; Toast . makeText ( this , R . string . toast_create_file_failed , Toast . LENGTH_LONG ) . show ( ) ; return false ; } } try { mOutputNMEALog = new FileOutputStream ( file ) ; } catch ( FileNotFoundException e1 ) { Log . w ( "@M_" + TAG , "output stream FileNotFoundException: " + e1 . getMessage ( ) ) ; return false ; } mTVNMEAHint . setText ( ( R . string . nmea_hint ) ) ; return true ; }
Create file to record nmea log.
Create file to record nmea log .
// set nmea hint