I am developing an Android application that creates a SQLite onCreate and queries records. All is working on my Android Emulator but when I deploy / debug on my Android Device (Samsung Galaxy 7 Edge) the database seems empty.
I have tested it on my emulator and works fine. Why is the SQLite not seems to be created / queried on my phone? Do I need additional permissions in my manifest?
Please help. Below is my code
package com.example.android.cebuanotagalogtranslator;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
    Button btn_clear;
    Button btn_translate_to_ceb;
    Button btn_translate_to_fil;
    EditText txt_input;
    EditText txt_output;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //HABAGAT CONTROLS BEGIN
        btn_clear = (Button) findViewById(R.id.btn_clear);
        btn_translate_to_ceb = (Button) findViewById(R.id.btn_trans_to_ceb);
        btn_translate_to_fil = (Button) findViewById(R.id.btn_trans_to_fil);
        txt_input = (EditText) findViewById(R.id.input);
        txt_output = (EditText) findViewById(R.id.output);
        //HABAGAT : CLEAR BOTH TEXT
        btn_clear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                txt_input.setText("");
                txt_output.setText("");
            }
        });
        //: FILIPINO -> CEBUANO
        btn_translate_to_ceb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    String textinput = txt_input.getText().toString();
                    textinput = "\""+ textinput +"\"";
                    String filToCebQuery = "SELECT ceb FROM filtoceb WHERE fil = "+ textinput+" "+"COLLATE NOCASE";
                    SQLiteDatabase DB = openOrCreateDatabase("filtoceb", MODE_PRIVATE, null);
                    //Cursor c = DB.rawQuery("SELECT * FROM filtoceb", null);
                    Cursor c = DB.rawQuery(filToCebQuery, null);
                    if (c!=null)
                    {
                        System.out.println("RESULT FOUND : FIL -> CEB");
                        try {
                            c.moveToFirst();
                            while(!c.isAfterLast()){
                                String result = c.getString(c.getColumnIndex("ceb"));
                                txt_output.setText(result);
                                c.moveToNext();
                            }
                        }
                        finally
                        {
                            c.close();
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        //: CEBUANO -> FILIPINO
        btn_translate_to_fil.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    String textinput = txt_input.getText().toString();
                    textinput = "\""+ textinput +"\"";
                    String filToCebQuery = "SELECT fil FROM filtoceb WHERE ceb = "+ textinput+" "+"COLLATE NOCASE";
                    SQLiteDatabase DB = openOrCreateDatabase("filtoceb", MODE_PRIVATE, null);
                    Cursor c = DB.rawQuery(filToCebQuery, null);
                    if (c!=null)
                        System.out.println("RESULT FOUND : CEB -> FIL ");
                    {
                        try {
                            c.moveToFirst();
                            while(!c.isAfterLast()){
                                String result = c.getString(c.getColumnIndex("fil"));
                                txt_output.setText(result);
                                c.moveToNext();
                            }
                        }
                        finally
                        {
                            c.close();
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        // CREATE DB OPEN IF NOT CREATED YET
        try {
            SQLiteDatabase eventsDB = this.openOrCreateDatabase("filtoceb", MODE_PRIVATE, null);
            //DELETE INITIALIZE SETUP START CLEAN
            eventsDB.delete("filtoceb", "1", null);
            eventsDB.execSQL("CREATE TABLE IF NOT EXISTS filtoceb (fil VARCHAR, ceb VARCHAR)");
            eventsDB.execSQL("INSERT INTO filtoceb (ceb, fil) VALUES ('Kumusta ka?','Kumusta ka?')");
            eventsDB.execSQL("INSERT INTO filtoceb (ceb, fil) VALUES ('Maayo, salamat', 'Mabuti naman, salamat')");
            eventsDB.execSQL("INSERT INTO filtoceb (ceb, fil) VALUES ('Unsay imong pangalan?',  'Ano pangalan mo?')");
            eventsDB.execSQL("INSERT INTO filtoceb (ceb, fil) VALUES ('Unsay ngalan mo?', 'ano pangalan mo?')");
            eventsDB.execSQL("INSERT INTO filtoceb (CEB, FIL) values ('Maayo nga nagka-ila ta', 'Ikinagagalak kitang makilala')");
            eventsDB.execSQL("INSERT INTO filtoceb (CEB, FIL) values ('Palihug','Please')");          
            eventsDB.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
below is my manifest:
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
 
     
    