السلام عليكم تحية طيبة للجميع كيف يمكننى اخذ نسخة احتياطية من قاعدة البيانات وحفظة فى اى مجلد على الهاتف
كتبت هذا الكود ولاكن يظهر خطا انه لايمكن الوصول الى ملف قاعدة البيانات
import { openDatabase } from 'react-native-sqlite-storage';
const [db, setDb] = useState(openDatabase({ name: 'applicationdiftare.db',location: 'default'}));
try {
const AppFolder = 'Business_Coustomers';
const DirectoryPath = RNFS.ExternalStorageDirectoryPath + '/Documents/' + AppFolder;
mkdir(DirectoryPath);
//هنا يتم النشاء الملف بنجاح
المشكلة هنا
لا يمكن الوصول الى مسار قاعدة البيانات
const sqliteDbPath = RNFS.DocumentDirectoryPath + '/applicationdiftare.db'; // مسار قاعدة البيانات
RNFS.copyFile(sqliteDbPath, '/storage/emulated/0/Documents/backup_database.db')
} catch (error) {
console.log('error')
}
التعليق السابق
قمت بالتنفيذ ولاكن تظهر error
[Error: ENOENT: /data/user/0/com.awesomeproject/files/applicationdiftare.db: open failed: ENOENT (No such file or directory), open '/data/user/0/com.awesomeproject/files/applicationdiftare.db']
الخطأ الذي تواجهه يشير إلى أن الملف الذي تحاول نسخه applicationdiftare.db غير موجود في المسار المحدد، تحقق من أنك تستخدم المسار الصحيح لقاعدة البيانات..
التعليقات