Using the same project I can create an FILE on my phone but on my tablet, what happens?

0

It's the same project, both have the permissions but on the tablet it does not let me create the file called MIARCHIVO

   File dbFile = context.getDatabasePath("BD_Ejemplo1.db");

    String archivo = "/data/mipackage/databases/BD_Ejemplo1.db";

    File folder = new File(Environment.getExternalStorageDirectory() +
            File.separator + "MIARCHIVO");
    boolean success = true;
    if (!folder.exists()) {
        success = folder.mkdirs();
    }
    if (success) {
        try {

            File sd = Environment.getExternalStorageDirectory();
            File dir = new File(sd.getAbsolutePath()+"/MIARCHIVO");
            dir.mkdirs();

            File data = Environment.getDataDirectory();

            if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
                System.out.println("ERROR");

            }else{
                System.out.println("DIR:  "+dir);
                String currentDBPath = archivo;
                //String backupDBPath = ";
                File currentDB = new File(data, currentDBPath);
                File backupDB = new File(dir,"/BD_Ejemplo1.db");

                FileChannel src = new FileInputStream(currentDB).getChannel();
                FileChannel dst = new FileOutputStream(backupDB).getChannel();
                dst.transferFrom(src, 0, src.size());
                src.close();
                dst.close();
                Toast.makeText(getApplicationContext(), "Backup Successful!",
                        Toast.LENGTH_SHORT).show();
            }
        } catch (Exception e) {

            Toast.makeText(getApplicationContext(), "Backup Failed!", Toast.LENGTH_SHORT)
                    .show();

        }
    } else {
        System.out.println("NO SE CREO CORRECTAMENTE");
    }
    eMail();
    
asked by Christian Arcadia 10.01.2018 в 19:19
source

0 answers