SQLite
 sql >> Database >  >> RDS >> SQLite

Emulatore vs dispositivo Samsung di archiviazione su scheda SD

Innanzitutto le informazioni per produrre questa risposta sono state fornite da @CommonsWareIt è pubblicato qui in modo che altri possano imparare di no in modo che io possa afferrare puntiIl problema era come gestire la posizione di archiviazione su un tablet SamsungÈ molto importante che tu comprenda il test se il La scheda SD è montata sull'emulatore non funzionerà Di seguito è riportato il mio codice molto strano per verificare se la scheda SD è stata montata o meno. Poi il codice rivisto che ti consente di gestire la posizione di archiviazione

    File fi = new File("storage/");
    File[] lst = fi.listFiles();//
    String top = String.valueOf(lst[1]);
    String bot = String.valueOf(lst[0]);

    if(bot.contains("-")){
        STORAGE_LOCATION = 1;
    }
    if(top.contains("storage/enc_emulated")){
        STORAGE_LOCATION = 0;
    }
    public String getThePath(){

    File removable = ContextCompat.getExternalFilesDirs(this,null) 
   [STORAGE_LOCATION];

    if(STORAGE_LOCATION == 1){
        THE_PATH = String.valueOf(removable);
        THE_PATH = THE_PATH + "/Documents/";
    }
    if(STORAGE_LOCATION == 0){
        THE_PATH = String.valueOf(removable);
        THE_PATH = THE_PATH + "/INTERNAL/";
        Toast.makeText(getApplicationContext(),"NO SD CARD", 
    Toast.LENGTH_LONG).show();
    }
        return THE_PATH;
}