I am inserting values to an Existing database stored in data>data>package_name>database
file. but while Inserting the values , Instead of getting stored in data.db
file, the values are auto-creating data.db-shm
and data.db-wal
files , and getting saved in it. I cant access the .db-shm and .db-wal file , but I can see from the modification time , that whenever I insert values these two files are modified not the actual one.
Below are my code -
MainActivity.java
package com.data.wifi;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import java.util.ArrayList;
public class MainActivity extends BridgeActivity {
DBHelper dbHelper = new DBHelper(this);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SQLiteDatabase db = dbHelper.getWritableDatabase();
db.execSQL("INSERT INTO applogs VALUES ('7760','Tue Oct 27 2020','Values inserted Successfully' )");
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
}});
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.clear();
}
}
DBHelper.java
package com.data.wifi;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DBHelper extends SQLiteOpenHelper {
public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "data.db";
public DBHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) { }
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { }
}
Whenever I am trying to run this code, two files are being created with same db name with different extensions (.db-shm and .db-shm) and it from the modification time , It looks like these two file are the ones getting modified all the time.In this pic wifi.db is the actual database file . but two other files are created automatically and looks like it is modifying only
PS- This code is working absolutely perfect in emulator, only when I try to run it on actual mobile device I am facing this issue. Edit- When I run the code in an emulator , the values are inserted in the original dbfile properly, and no such shm and wal files are created there . I am seeing this is an issue , because when I try to extract my db file , i dont see my inserted values there. neithr the db file looks modified