SQLiteOpenHelper no response on query












0














I try to make my app, it's kinda dictionary with training staff. But I'm stuck at this moment:
I need insert statistic of word (correct and incorrect answer), but all query finish with errors:



<code>E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.maxvek.myapplication, PID: 9088
android.database.CursorIndexOutOfBoundsException:Index -1 requested,with a size of 1</code>


or something like this:



no response from DB


I tried make same query at sqliteonline and this work.



I just don't know what to do. I read some stuff and I think what I need some callback. But I'm new to java and can't even understand how to do it.



My class:



DatabaseHelper



public class DatabaseHelper extends SQLiteOpenHelper {
sqLiteDatabase.execSQL("create table " + TABLE_NAME + " (id INTEGER PRIMARY KEY AUTOINCREMENT,uk TEXT, en TEXT, ru TEXT, de TEXT, fr TEXT)");
sqLiteDatabase.execSQL("create table " + TABLE_STAT_WORD + " (id INTEGER PRIMARY KEY AUTOINCREMENT,uk TEXT, en TEXT, ru TEXT, de TEXT, fr TEXT, cor INTEGER, incor INTEGER)");
...

public void insertStatWord(String word, String lang, Boolean answer) {
SQLiteDatabase db = this.getWritableDatabase();
Cursor res = db.rawQuery("select id from " + TABLE_NAME + " where " + lang + " = '" + word + "' limit(1)", null);
String id = res.getString(0);
if (answer) {
Cursor update = db.rawQuery("update " + TABLE_STAT_WORD + " set cor = cor+1 WHERE " + lang + " = " + id, null);
if (update == null) {
ContentValues contentValues = new ContentValues();
contentValues.put(lang, id);
contentValues.put("cor", 1);
db.insert(TABLE_STAT_WORD, null, contentValues);
}
} else {
Cursor update = db.rawQuery("update " + TABLE_STAT_WORD + " set incor = incor+1 WHERE " + lang + " = " + id, null);
if (update == null) {
ContentValues contentValues = new ContentValues();
contentValues.put(lang, id);
contentValues.put("incor", 1);
db.insert(TABLE_STAT_WORD, null, contentValues);
}
}
...
}


DatabaseInstance



public class DatabaseInstance {
private static DatabaseInstance ourInstance = new DatabaseInstance();
private DatabaseHelper myDB;

private DatabaseInstance() {
}

public static DatabaseInstance getInstance() {
return ourInstance;
}

public synchronized void init(Context context) {
if (myDB == null) {
myDB = new DatabaseHelper(context);
}
}

public DatabaseHelper getMyDB() {
return myDB;
}
}


From this fragment I try call this method:




TrainingFragment



private void statOfWord(String word, String lang, boolean answer) {
DatabaseInstance.getInstance().getMyDB().insertStatWord(word, lang, answer);
}









share|improve this question





























    0














    I try to make my app, it's kinda dictionary with training staff. But I'm stuck at this moment:
    I need insert statistic of word (correct and incorrect answer), but all query finish with errors:



    <code>E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.maxvek.myapplication, PID: 9088
    android.database.CursorIndexOutOfBoundsException:Index -1 requested,with a size of 1</code>


    or something like this:



    no response from DB


    I tried make same query at sqliteonline and this work.



    I just don't know what to do. I read some stuff and I think what I need some callback. But I'm new to java and can't even understand how to do it.



    My class:



    DatabaseHelper



    public class DatabaseHelper extends SQLiteOpenHelper {
    sqLiteDatabase.execSQL("create table " + TABLE_NAME + " (id INTEGER PRIMARY KEY AUTOINCREMENT,uk TEXT, en TEXT, ru TEXT, de TEXT, fr TEXT)");
    sqLiteDatabase.execSQL("create table " + TABLE_STAT_WORD + " (id INTEGER PRIMARY KEY AUTOINCREMENT,uk TEXT, en TEXT, ru TEXT, de TEXT, fr TEXT, cor INTEGER, incor INTEGER)");
    ...

    public void insertStatWord(String word, String lang, Boolean answer) {
    SQLiteDatabase db = this.getWritableDatabase();
    Cursor res = db.rawQuery("select id from " + TABLE_NAME + " where " + lang + " = '" + word + "' limit(1)", null);
    String id = res.getString(0);
    if (answer) {
    Cursor update = db.rawQuery("update " + TABLE_STAT_WORD + " set cor = cor+1 WHERE " + lang + " = " + id, null);
    if (update == null) {
    ContentValues contentValues = new ContentValues();
    contentValues.put(lang, id);
    contentValues.put("cor", 1);
    db.insert(TABLE_STAT_WORD, null, contentValues);
    }
    } else {
    Cursor update = db.rawQuery("update " + TABLE_STAT_WORD + " set incor = incor+1 WHERE " + lang + " = " + id, null);
    if (update == null) {
    ContentValues contentValues = new ContentValues();
    contentValues.put(lang, id);
    contentValues.put("incor", 1);
    db.insert(TABLE_STAT_WORD, null, contentValues);
    }
    }
    ...
    }


    DatabaseInstance



    public class DatabaseInstance {
    private static DatabaseInstance ourInstance = new DatabaseInstance();
    private DatabaseHelper myDB;

    private DatabaseInstance() {
    }

    public static DatabaseInstance getInstance() {
    return ourInstance;
    }

    public synchronized void init(Context context) {
    if (myDB == null) {
    myDB = new DatabaseHelper(context);
    }
    }

    public DatabaseHelper getMyDB() {
    return myDB;
    }
    }


    From this fragment I try call this method:




    TrainingFragment



    private void statOfWord(String word, String lang, boolean answer) {
    DatabaseInstance.getInstance().getMyDB().insertStatWord(word, lang, answer);
    }









    share|improve this question



























      0












      0








      0







      I try to make my app, it's kinda dictionary with training staff. But I'm stuck at this moment:
      I need insert statistic of word (correct and incorrect answer), but all query finish with errors:



      <code>E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.maxvek.myapplication, PID: 9088
      android.database.CursorIndexOutOfBoundsException:Index -1 requested,with a size of 1</code>


      or something like this:



      no response from DB


      I tried make same query at sqliteonline and this work.



      I just don't know what to do. I read some stuff and I think what I need some callback. But I'm new to java and can't even understand how to do it.



      My class:



      DatabaseHelper



      public class DatabaseHelper extends SQLiteOpenHelper {
      sqLiteDatabase.execSQL("create table " + TABLE_NAME + " (id INTEGER PRIMARY KEY AUTOINCREMENT,uk TEXT, en TEXT, ru TEXT, de TEXT, fr TEXT)");
      sqLiteDatabase.execSQL("create table " + TABLE_STAT_WORD + " (id INTEGER PRIMARY KEY AUTOINCREMENT,uk TEXT, en TEXT, ru TEXT, de TEXT, fr TEXT, cor INTEGER, incor INTEGER)");
      ...

      public void insertStatWord(String word, String lang, Boolean answer) {
      SQLiteDatabase db = this.getWritableDatabase();
      Cursor res = db.rawQuery("select id from " + TABLE_NAME + " where " + lang + " = '" + word + "' limit(1)", null);
      String id = res.getString(0);
      if (answer) {
      Cursor update = db.rawQuery("update " + TABLE_STAT_WORD + " set cor = cor+1 WHERE " + lang + " = " + id, null);
      if (update == null) {
      ContentValues contentValues = new ContentValues();
      contentValues.put(lang, id);
      contentValues.put("cor", 1);
      db.insert(TABLE_STAT_WORD, null, contentValues);
      }
      } else {
      Cursor update = db.rawQuery("update " + TABLE_STAT_WORD + " set incor = incor+1 WHERE " + lang + " = " + id, null);
      if (update == null) {
      ContentValues contentValues = new ContentValues();
      contentValues.put(lang, id);
      contentValues.put("incor", 1);
      db.insert(TABLE_STAT_WORD, null, contentValues);
      }
      }
      ...
      }


      DatabaseInstance



      public class DatabaseInstance {
      private static DatabaseInstance ourInstance = new DatabaseInstance();
      private DatabaseHelper myDB;

      private DatabaseInstance() {
      }

      public static DatabaseInstance getInstance() {
      return ourInstance;
      }

      public synchronized void init(Context context) {
      if (myDB == null) {
      myDB = new DatabaseHelper(context);
      }
      }

      public DatabaseHelper getMyDB() {
      return myDB;
      }
      }


      From this fragment I try call this method:




      TrainingFragment



      private void statOfWord(String word, String lang, boolean answer) {
      DatabaseInstance.getInstance().getMyDB().insertStatWord(word, lang, answer);
      }









      share|improve this question















      I try to make my app, it's kinda dictionary with training staff. But I'm stuck at this moment:
      I need insert statistic of word (correct and incorrect answer), but all query finish with errors:



      <code>E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.maxvek.myapplication, PID: 9088
      android.database.CursorIndexOutOfBoundsException:Index -1 requested,with a size of 1</code>


      or something like this:



      no response from DB


      I tried make same query at sqliteonline and this work.



      I just don't know what to do. I read some stuff and I think what I need some callback. But I'm new to java and can't even understand how to do it.



      My class:



      DatabaseHelper



      public class DatabaseHelper extends SQLiteOpenHelper {
      sqLiteDatabase.execSQL("create table " + TABLE_NAME + " (id INTEGER PRIMARY KEY AUTOINCREMENT,uk TEXT, en TEXT, ru TEXT, de TEXT, fr TEXT)");
      sqLiteDatabase.execSQL("create table " + TABLE_STAT_WORD + " (id INTEGER PRIMARY KEY AUTOINCREMENT,uk TEXT, en TEXT, ru TEXT, de TEXT, fr TEXT, cor INTEGER, incor INTEGER)");
      ...

      public void insertStatWord(String word, String lang, Boolean answer) {
      SQLiteDatabase db = this.getWritableDatabase();
      Cursor res = db.rawQuery("select id from " + TABLE_NAME + " where " + lang + " = '" + word + "' limit(1)", null);
      String id = res.getString(0);
      if (answer) {
      Cursor update = db.rawQuery("update " + TABLE_STAT_WORD + " set cor = cor+1 WHERE " + lang + " = " + id, null);
      if (update == null) {
      ContentValues contentValues = new ContentValues();
      contentValues.put(lang, id);
      contentValues.put("cor", 1);
      db.insert(TABLE_STAT_WORD, null, contentValues);
      }
      } else {
      Cursor update = db.rawQuery("update " + TABLE_STAT_WORD + " set incor = incor+1 WHERE " + lang + " = " + id, null);
      if (update == null) {
      ContentValues contentValues = new ContentValues();
      contentValues.put(lang, id);
      contentValues.put("incor", 1);
      db.insert(TABLE_STAT_WORD, null, contentValues);
      }
      }
      ...
      }


      DatabaseInstance



      public class DatabaseInstance {
      private static DatabaseInstance ourInstance = new DatabaseInstance();
      private DatabaseHelper myDB;

      private DatabaseInstance() {
      }

      public static DatabaseInstance getInstance() {
      return ourInstance;
      }

      public synchronized void init(Context context) {
      if (myDB == null) {
      myDB = new DatabaseHelper(context);
      }
      }

      public DatabaseHelper getMyDB() {
      return myDB;
      }
      }


      From this fragment I try call this method:




      TrainingFragment



      private void statOfWord(String word, String lang, boolean answer) {
      DatabaseInstance.getInstance().getMyDB().insertStatWord(word, lang, answer);
      }






      java android android-sqlite






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 '18 at 13:43









      Fantômas

      32.3k156288




      32.3k156288










      asked Nov 12 '18 at 12:08









      MaXiM4Uk

      31




      31
























          1 Answer
          1






          active

          oldest

          votes


















          0














          The cursor returned by this:



          Cursor res = db.rawQuery("select id from " + TABLE_NAME + " where " + lang + " = '" + word + "' limit(1)", null);


          may or may not contain 1 row, so you must check it:



          String id = "";
          if (res.moveToFirst()){
          id = res.getString(cursor.getColumnIndex(0));
          }
          if (id.isEmpty())
          return;



          Also in your code you need twice to execute update statements but you do it by executing the wrong method.

          The method rawQuery() is used to fetch data from a table by a SELECT statement and not to update data.

          Instead you must use the method execSQL() which does not return anything, like this:



          db.execSQL("update " + TABLE_STAT_WORD + " set cor = cor + 1 WHERE " + lang + " = " + id);


          and



          db.execSQL("update " + TABLE_STAT_WORD + " set incor = incor + 1 WHERE " + lang + " = " + id);





          share|improve this answer





















          • ty dude, all working, your and @Prasanth realy help me. About update, i try to do "Update or Insert", so basically it's 1 update, but ty for explaining this)
            – MaXiM4Uk
            Nov 12 '18 at 15:25










          • @MaXiM4Uk did you change to execSQL?
            – forpas
            Nov 12 '18 at 15:27










          • no, execSQL it's void, i need check if update was success, or i should check by executeUpdate() ?
            – MaXiM4Uk
            Nov 12 '18 at 15:45










          • actually i was wrong, i change code: db.execSQL("update " + TABLE_STAT_WORD + " set cor = cor + 1 WHERE " + lang + " = " + id); long update = DatabaseUtils.longForQuery(db, "SELECT changes()", null); if (update == 0){ ContentValues contentValues = new ContentValues(); contentValues.put(lang, id); contentValues.put("cor", 1); contentValues.put("incor", 0); db.insert(TABLE_STAT_WORD, null, contentValues); }
            – MaXiM4Uk
            Nov 12 '18 at 16:32













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53261895%2fsqliteopenhelper-no-response-on-query%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          The cursor returned by this:



          Cursor res = db.rawQuery("select id from " + TABLE_NAME + " where " + lang + " = '" + word + "' limit(1)", null);


          may or may not contain 1 row, so you must check it:



          String id = "";
          if (res.moveToFirst()){
          id = res.getString(cursor.getColumnIndex(0));
          }
          if (id.isEmpty())
          return;



          Also in your code you need twice to execute update statements but you do it by executing the wrong method.

          The method rawQuery() is used to fetch data from a table by a SELECT statement and not to update data.

          Instead you must use the method execSQL() which does not return anything, like this:



          db.execSQL("update " + TABLE_STAT_WORD + " set cor = cor + 1 WHERE " + lang + " = " + id);


          and



          db.execSQL("update " + TABLE_STAT_WORD + " set incor = incor + 1 WHERE " + lang + " = " + id);





          share|improve this answer





















          • ty dude, all working, your and @Prasanth realy help me. About update, i try to do "Update or Insert", so basically it's 1 update, but ty for explaining this)
            – MaXiM4Uk
            Nov 12 '18 at 15:25










          • @MaXiM4Uk did you change to execSQL?
            – forpas
            Nov 12 '18 at 15:27










          • no, execSQL it's void, i need check if update was success, or i should check by executeUpdate() ?
            – MaXiM4Uk
            Nov 12 '18 at 15:45










          • actually i was wrong, i change code: db.execSQL("update " + TABLE_STAT_WORD + " set cor = cor + 1 WHERE " + lang + " = " + id); long update = DatabaseUtils.longForQuery(db, "SELECT changes()", null); if (update == 0){ ContentValues contentValues = new ContentValues(); contentValues.put(lang, id); contentValues.put("cor", 1); contentValues.put("incor", 0); db.insert(TABLE_STAT_WORD, null, contentValues); }
            – MaXiM4Uk
            Nov 12 '18 at 16:32


















          0














          The cursor returned by this:



          Cursor res = db.rawQuery("select id from " + TABLE_NAME + " where " + lang + " = '" + word + "' limit(1)", null);


          may or may not contain 1 row, so you must check it:



          String id = "";
          if (res.moveToFirst()){
          id = res.getString(cursor.getColumnIndex(0));
          }
          if (id.isEmpty())
          return;



          Also in your code you need twice to execute update statements but you do it by executing the wrong method.

          The method rawQuery() is used to fetch data from a table by a SELECT statement and not to update data.

          Instead you must use the method execSQL() which does not return anything, like this:



          db.execSQL("update " + TABLE_STAT_WORD + " set cor = cor + 1 WHERE " + lang + " = " + id);


          and



          db.execSQL("update " + TABLE_STAT_WORD + " set incor = incor + 1 WHERE " + lang + " = " + id);





          share|improve this answer





















          • ty dude, all working, your and @Prasanth realy help me. About update, i try to do "Update or Insert", so basically it's 1 update, but ty for explaining this)
            – MaXiM4Uk
            Nov 12 '18 at 15:25










          • @MaXiM4Uk did you change to execSQL?
            – forpas
            Nov 12 '18 at 15:27










          • no, execSQL it's void, i need check if update was success, or i should check by executeUpdate() ?
            – MaXiM4Uk
            Nov 12 '18 at 15:45










          • actually i was wrong, i change code: db.execSQL("update " + TABLE_STAT_WORD + " set cor = cor + 1 WHERE " + lang + " = " + id); long update = DatabaseUtils.longForQuery(db, "SELECT changes()", null); if (update == 0){ ContentValues contentValues = new ContentValues(); contentValues.put(lang, id); contentValues.put("cor", 1); contentValues.put("incor", 0); db.insert(TABLE_STAT_WORD, null, contentValues); }
            – MaXiM4Uk
            Nov 12 '18 at 16:32
















          0












          0








          0






          The cursor returned by this:



          Cursor res = db.rawQuery("select id from " + TABLE_NAME + " where " + lang + " = '" + word + "' limit(1)", null);


          may or may not contain 1 row, so you must check it:



          String id = "";
          if (res.moveToFirst()){
          id = res.getString(cursor.getColumnIndex(0));
          }
          if (id.isEmpty())
          return;



          Also in your code you need twice to execute update statements but you do it by executing the wrong method.

          The method rawQuery() is used to fetch data from a table by a SELECT statement and not to update data.

          Instead you must use the method execSQL() which does not return anything, like this:



          db.execSQL("update " + TABLE_STAT_WORD + " set cor = cor + 1 WHERE " + lang + " = " + id);


          and



          db.execSQL("update " + TABLE_STAT_WORD + " set incor = incor + 1 WHERE " + lang + " = " + id);





          share|improve this answer












          The cursor returned by this:



          Cursor res = db.rawQuery("select id from " + TABLE_NAME + " where " + lang + " = '" + word + "' limit(1)", null);


          may or may not contain 1 row, so you must check it:



          String id = "";
          if (res.moveToFirst()){
          id = res.getString(cursor.getColumnIndex(0));
          }
          if (id.isEmpty())
          return;



          Also in your code you need twice to execute update statements but you do it by executing the wrong method.

          The method rawQuery() is used to fetch data from a table by a SELECT statement and not to update data.

          Instead you must use the method execSQL() which does not return anything, like this:



          db.execSQL("update " + TABLE_STAT_WORD + " set cor = cor + 1 WHERE " + lang + " = " + id);


          and



          db.execSQL("update " + TABLE_STAT_WORD + " set incor = incor + 1 WHERE " + lang + " = " + id);






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 '18 at 14:03









          forpas

          8,4891421




          8,4891421












          • ty dude, all working, your and @Prasanth realy help me. About update, i try to do "Update or Insert", so basically it's 1 update, but ty for explaining this)
            – MaXiM4Uk
            Nov 12 '18 at 15:25










          • @MaXiM4Uk did you change to execSQL?
            – forpas
            Nov 12 '18 at 15:27










          • no, execSQL it's void, i need check if update was success, or i should check by executeUpdate() ?
            – MaXiM4Uk
            Nov 12 '18 at 15:45










          • actually i was wrong, i change code: db.execSQL("update " + TABLE_STAT_WORD + " set cor = cor + 1 WHERE " + lang + " = " + id); long update = DatabaseUtils.longForQuery(db, "SELECT changes()", null); if (update == 0){ ContentValues contentValues = new ContentValues(); contentValues.put(lang, id); contentValues.put("cor", 1); contentValues.put("incor", 0); db.insert(TABLE_STAT_WORD, null, contentValues); }
            – MaXiM4Uk
            Nov 12 '18 at 16:32




















          • ty dude, all working, your and @Prasanth realy help me. About update, i try to do "Update or Insert", so basically it's 1 update, but ty for explaining this)
            – MaXiM4Uk
            Nov 12 '18 at 15:25










          • @MaXiM4Uk did you change to execSQL?
            – forpas
            Nov 12 '18 at 15:27










          • no, execSQL it's void, i need check if update was success, or i should check by executeUpdate() ?
            – MaXiM4Uk
            Nov 12 '18 at 15:45










          • actually i was wrong, i change code: db.execSQL("update " + TABLE_STAT_WORD + " set cor = cor + 1 WHERE " + lang + " = " + id); long update = DatabaseUtils.longForQuery(db, "SELECT changes()", null); if (update == 0){ ContentValues contentValues = new ContentValues(); contentValues.put(lang, id); contentValues.put("cor", 1); contentValues.put("incor", 0); db.insert(TABLE_STAT_WORD, null, contentValues); }
            – MaXiM4Uk
            Nov 12 '18 at 16:32


















          ty dude, all working, your and @Prasanth realy help me. About update, i try to do "Update or Insert", so basically it's 1 update, but ty for explaining this)
          – MaXiM4Uk
          Nov 12 '18 at 15:25




          ty dude, all working, your and @Prasanth realy help me. About update, i try to do "Update or Insert", so basically it's 1 update, but ty for explaining this)
          – MaXiM4Uk
          Nov 12 '18 at 15:25












          @MaXiM4Uk did you change to execSQL?
          – forpas
          Nov 12 '18 at 15:27




          @MaXiM4Uk did you change to execSQL?
          – forpas
          Nov 12 '18 at 15:27












          no, execSQL it's void, i need check if update was success, or i should check by executeUpdate() ?
          – MaXiM4Uk
          Nov 12 '18 at 15:45




          no, execSQL it's void, i need check if update was success, or i should check by executeUpdate() ?
          – MaXiM4Uk
          Nov 12 '18 at 15:45












          actually i was wrong, i change code: db.execSQL("update " + TABLE_STAT_WORD + " set cor = cor + 1 WHERE " + lang + " = " + id); long update = DatabaseUtils.longForQuery(db, "SELECT changes()", null); if (update == 0){ ContentValues contentValues = new ContentValues(); contentValues.put(lang, id); contentValues.put("cor", 1); contentValues.put("incor", 0); db.insert(TABLE_STAT_WORD, null, contentValues); }
          – MaXiM4Uk
          Nov 12 '18 at 16:32






          actually i was wrong, i change code: db.execSQL("update " + TABLE_STAT_WORD + " set cor = cor + 1 WHERE " + lang + " = " + id); long update = DatabaseUtils.longForQuery(db, "SELECT changes()", null); if (update == 0){ ContentValues contentValues = new ContentValues(); contentValues.put(lang, id); contentValues.put("cor", 1); contentValues.put("incor", 0); db.insert(TABLE_STAT_WORD, null, contentValues); }
          – MaXiM4Uk
          Nov 12 '18 at 16:32




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53261895%2fsqliteopenhelper-no-response-on-query%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Error while running script in elastic search , gateway timeout

          Adding quotations to stringified JSON object values