Sqlite Android 9

Asked

Viewed 39 times

0

I’m having trouble working with my app on Android 9. On some devices that were Android 8 and have upgraded to Android 9 works, but on the devices that comes with a newer version of Android 9 factory it fails to bring the data. I already made the test and the database is being copied to the data area of the device, but does not bring the information. I will post the code I am using so that if possible someone will help me. If you have some grotesque error forgive me, for I am a beginner in language. Note: In versions prior to 9 works perfectly.

Thank you very much.

public class Repositorioconfiguracao {

private static final String NOME_BANCO = "MB_DADOS";

protected SQLiteDatabase db;

public class MySQLiteOpenHelper extends SQLiteOpenHelper {

    MySQLiteOpenHelper(Context context, String databaseName) {
        super(context, databaseName, null, 2);

    }

    @Override
    public void onCreate(SQLiteDatabase db) {
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}


public RepositorioConfiguracao(Context ctx) {


    if (android.os.Build.VERSION.SDK_INT >= 26) {
        MySQLiteOpenHelper helper = new MySQLiteOpenHelper(ctx, NOME_BANCO);
        SQLiteDatabase database = helper.getReadableDatabase();
        String myPath = database.getPath();
        Log.i("Eficaz","Path = "+myPath);
        db = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READWRITE);
        db.disableWriteAheadLogging();

        } else {
            db = ctx.openOrCreateDatabase(NOME_BANCO, Context.MODE_PRIVATE, null);
        }

}



public DbConfiguracao BuscaConfig(int Empresa) {
    DbConfiguracao config = null;

    try {
  • tried a logcat to see if it was generating an error ?

  • My application was created with API 19, whenever I test on the emulator or some device in this version no error. I could not run on an emulator or device with API28 because it gives a device message is not compatible.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.