I have tried two methods
METHOD 1
private void CopyAssets() {
AssetManager assetManager = getAssets();
String[] files = null;
try {
files = assetManager.list("myfoldername");
} catch (IOException e) {
Log.e("tag", e.getMessage());
}
for(String filename : files) {
InputStream in = null;
OutputStream out = null;
try {
RootTools.remount("/system/app/", "rw");
in = assetManager.open("myfoldername/"+filename);
out = new FileOutputStream("/system/app/" + filename);
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
} catch(Exception e) {
Log.e("tag", e.getMessage());
}
}
}
private void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1){
out.write(buffer, 0, read);
}
}
in the above method i am getting /system/app/filename: open failed: EROFS (Read-only file system) error
METHOD 2:
private void method_to_copy(String app,String localFolder)
{
AssetManager assetManager = getAssets();
String[] files = null;
try {
files = assetManager.list(localFolder);
for(int i=0;i<files.length;i++){
RootTools.remount("/system/app/", "rw");
Runtime.getRuntime().exec("su cat " + "localFolder/" + files[i] + " > " + "/system/" + systemFolder+"/"+ files[i] );
}
} catch (IOException e) {
Log.w("tag", e.getMessage());
}
}
using this method the file is copied but becomes corrupted
Note: 1.I have rooted the device first 2.I am using root tool library to remount system folder rw permission