में संपत्ति फ़ोल्डर से डेटाबेस कॉपी करें मैं डीबी को संपत्ति फ़ोल्डर से डिवाइस में कॉपी करने की कोशिश कर रहा हूं। यह कोड एमुलेटर और रूट डिवाइस पर ठीक काम कर रहा है। मैं सिर्फ यह जानना चाहता हूं कि यह अनियंत्रित डिवाइस पर कोई समस्या पैदा करता है या यह वही काम करेगा।अनियंत्रित डिवाइस
private void StoreDatabase() {
File DbFile = new File(
"data/data/packagename/DBname.sqlite");
if (DbFile.exists()) {
System.out.println("file already exist ,No need to Create");
} else {
try {
DbFile.createNewFile();
System.out.println("File Created successfully");
InputStream is = this.getAssets().open("DBname.sqlite");
FileOutputStream fos = new FileOutputStream(DbFile);
byte[] buffer = new byte[1024];
int length = 0;
while ((length = is.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
System.out.println("File succesfully placed on sdcard");
// Close the streams
fos.flush();
fos.close();
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
हाँ अपने कोड स्निपेट unrooted उपकरणों पर पूरी तरह से काम करता है भी :) –