The second day cannot be done elementary: copy this elusive file. Here is the code:
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { Toast.makeText(getApplicationContext(), "SD-ΠΊΠ°ΡΡΠ° Π½Π΅ Π΄ΠΎΡΡΡΠΏΠ½Π°: " + Environment.getExternalStorageState(), Toast.LENGTH_LONG).show(); } else { Toast.makeText(getApplicationContext(), "SD-ΠΊΠ°ΡΡΠ° Π΄ΠΎΡΡΡΠΏΠ½Π°: " + Environment.getExternalStorageState(), Toast.LENGTH_LONG).show(); // ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΠΏΡΡΡ ΠΊ SD File sdPath = getExternalFilesDir(null); // Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ ΡΠ²ΠΎΠΉ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ ΠΊ ΠΏΡΡΠΈ sdPath = new File(sdPath.getAbsolutePath()); // ΡΠΎΠ·Π΄Π°Π΅ΠΌ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ if (!sdPath.exists()) { sdPath.mkdirs(); Toast.makeText(getApplicationContext(), "ΡΠΎΠ·Π΄Π°Π»ΠΈ ΠΏΠ°ΠΏΠΊΡ", Toast.LENGTH_LONG).show(); } try { // ΠΎΡΠΊΡΡΠ²Π°Π΅ΠΌ ΠΏΠΎΡΠΎΠΊΠΈ Π΄Π»Ρ Π·Π°ΠΏΠΈΡΠΈ File fFrom = new File(this.getDatabasePath("DBtimes.db").getAbsolutePath(), "DBtimes.db"); File fTo = new File(sdPath, "CH_" + s_now + ".db"); InputStream in = new FileInputStream(fFrom); OutputStream out = new FileOutputStream(fTo); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } // ΠΠ°ΠΊΡΡΠ²Π°Π΅ΠΌ ΠΏΠΎΡΠΎΠΊΠΈ in.close(); out.close(); Toast.makeText(getApplicationContext(), s_now + "ΠΊΠΎΠΏΠΈΡΡΠ΅ΠΌ ΡΠ°ΠΉΠ» ", Toast.LENGTH_LONG).show(); } catch (FileNotFoundException ex) { Toast.makeText(getApplicationContext(), "Π½Π΅ Π½Π°ΡΠ»ΠΈ ΡΠ°ΠΉΠ»", Toast.LENGTH_LONG).show(); } catch (IOException e) { Toast.makeText(getApplicationContext(), "Π΄ΡΡΠ³Π°Ρ ΠΎΡΠΈΠ±ΠΊΠ°", Toast.LENGTH_LONG).show(); } What I just did not write here:
File fFrom = new File(this.getDatabasePath("DBtimes.db").getAbsolutePath(), "DBtimes.db"); and
File fFrom = new File("/data/data/ΠΈΠΌΡ_ΠΏΠ°ΠΊΠ΅ΡΠ°/databases/DBtimes.db"); and just
File(getDatabasePath("DBtimes.db").getAbsolutePath(), "DBtimes.db"); And with the extension .db and without, and tried to copy the open database, and closed. It also doesn't work like this:
File fFrom = new File(getApplicationContext().getDatabasePath("DBtimes.db").getAbsolutePath(), "DBtimes.db"); but
Π‘ontext.getDatabasePath("DBtimes.db").getAbsolutePath(); Paints the word Π‘ontext red or otherwise writes that the non-static getDatabasePath ("DBtimes.db") cannot be used with the static Π‘ontext. What is wrong?