Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.wreighn.fpsswitch;
- import android.content.res.AssetManager;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.util.Log;
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.InputStream;
- import java.io.OutputStream;
- public class MainActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- File mprof = new File("/system/etc/media_profiles.xml");
- if(mprof.exists()) {
- //return true;
- Log.d("Postojanje","DA");
- }
- else{
- //return false;
- Log.d("Postojanje","NE");
- copyFile("media_profiles.xml");
- }
- }
- private void copyFile(String filename) {
- AssetManager assetManager = this.getAssets();
- InputStream in = null;
- OutputStream out = null;
- try {
- in = assetManager.open(filename);
- String newFileName = "/sdcard/" + filename;
- out = new FileOutputStream(newFileName);
- byte[] buffer = new byte[1024];
- int read;
- while ((read = in.read(buffer)) != -1) {
- out.write(buffer, 0, read);
- }
- in.close();
- in = null;
- out.flush();
- out.close();
- out = null;
- } catch (Exception e) {
- Log.e("tag", e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement