0

I have a code that works fine, in eclipse, but the apk when instaled in my smartphone and i do a search at the database show me a message of"invalid double". Anyone can say why this happens? Thanks

if (chkTipo.isChecked() != true
                    && spinAno.getSelectedItem().toString() != "Ano"
                    && spinMes.getSelectedItem().toString() == "Mes"
                    && spinDia.getSelectedItem().toString() == "Dia") {
                Bundle extras = new Bundle();

                String year = tvData1.getText().toString()
                        .replace("Data: ", "");
                extras.putString("year", year);
                sumToView = Double.parseDouble(tvValor.getText().toString()
                        .replace("R$    : ", ""));
                Toast_msg = "Ano" + year;
                Show_Toast(Toast_msg);
                extras.putDouble("sum", sumToView);
                extras.putString("criterio", "ano");

                view_user.putExtras(extras);
                view_user.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
                        | Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(view_user);
                finish();

            }

Helper

    public void onCreate(SQLiteDatabase db) {
    try {
        String CREATE_TRANSACOES_TABLE = "CREATE TABLE " + TABLE_TRANSACOES
                + "(" + KEY_ID + " INTEGER PRIMARY KEY," + DAY + " TEXT,"
                + MONTH + " TEXT," + YEAR + " TEXT," + ID_FROM_DESPESA
                + " INTEGER," + NOME_FROM_DESPESA + " TEXT," + KEY_VALUE
                + " double" + ")";

        String CREATE_DESPESA_TABLE = "CREATE TABLE " + TABLE_DESPESAS
                + "(" + ID_DESPESA + " INTEGER PRIMARY KEY," + NOME_DESPESA
                + " TEXT" + ")";

        db.execSQL(CREATE_DESPESA_TABLE);

        db.execSQL(CREATE_TRANSACOES_TABLE);
    } catch (SQLException se) {
        Log.v("DatabaseHandler Oncreate SQLException",
                Log.getStackTraceString(se));
    } catch (Exception e) {
        Log.v("DatabaseHandler Oncreate Exception",
                Log.getStackTraceString(e));
    }
}
Rodrigo
  • 153
  • 2
  • 9
  • please post related code here – Zeeshan Khan Jul 22 '14 at 03:48
  • As i said, in the IDE Eclipse, it works fine, just when i install on my smartphone, it shows the error "Invalid double". I'll try with an different API...Thanks – Rodrigo Jul 22 '14 at 04:14
  • where is your code for creating the sqlite database? when it works in eclipse are you simply running java code (in a java project) or android code on an AVD? – Hector Jul 22 '14 at 04:16
  • What do you mean with "message"? Is it that toast? Some exception? – CL. Jul 22 '14 at 06:48
  • The `Double.parseDouble()` seems error-prone. Also consider http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java – laalto Jul 22 '14 at 06:50
  • I'll check this at night laalto, thanks and yes, the error is wnen i insall apk to the phone. The "message is a exception." – Rodrigo Jul 22 '14 at 10:28
  • When i run the app in an AVD device (Eclipse), it show the double with" . " Like 3.33 but on the phone, it shows the double values with " , " Like 3,33 would that be the problem causing the error? – Rodrigo Jul 22 '14 at 16:01

0 Answers0