Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
164 views
in Technique[技术] by (71.8m points)

How can i transfer a DATABASE_NAME from sharedpreferences to my SQLiteOpenhelper class?

`In my MainActivity3, i use a function lire(), i retrieve DATABASE_NAME

 private String lire()
{
    SharedPreferences sh = getApplicationContext().getSharedPreferences("Test", 0);
    SharedPreferences.Editor editor = sh.edit();
    String x1 = sh.getString("Langue", null);
    String x2 = sh.getString("Pointdepart", null);
    String x3 = sh.getString("NbPoints", null);
    String x4 = sh.getString("Bdd", null);
    String x5 = sh.getString("CodeBdd", null);
    Langue = x1;
    DATABASE_NAME = x5;
    return DATABASE_NAME;
}

In my SqliteHelpler Class

public class SQLiteHelper extends SQLiteOpenHelper {

public static final String DATABASE_NAME = "lgmfr";
private static Context appContext;

public SQLiteHelper(Context applicationcontext ) {
    super(applicationcontext, DATABASE_NAME, null, 1);
    this.appContext =  applicationcontext;

}
  • don't know how to replace DATABASE_NAME = "lgmfr" by DATABASE_NAME from sharedpreferences Thank's for your help*
question from:https://stackoverflow.com/questions/65925495/how-can-i-transfer-a-database-name-from-sharedpreferences-to-my-sqliteopenhelper

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...