I tried adding
dst.createNewFile();

Got a
09-16 14:35:39.569: WARN/System.err(1137): java.io.IOException:
Read-only file system
09-16 14:35:39.579: WARN/System.err(1137):     at
java.io.File.createNewFileImpl(Native Method)
09-16 14:35:39.579: WARN/System.err(1137):     at
java.io.File.createNewFile(File.java:1160)
09-16 14:35:39.588: WARN/System.err(1137):     at
com.sears.rsync.DeployRSync.copy(DeployRSync.java:33)
09-16 14:35:39.601: WARN/System.err(1137):     at
com.sears.rsync.DeployRSync.onCreate(DeployRSync.java:24)

My android manifest has

<manifest xmlns:android="http://schemas.android.com/apk/res/android";
        package="com.sears.rsync" android:versionCode="1" 
android:versionName="1.0">
        <uses-sdk android:minSdkVersion="8" />
        <uses-permission
android:name="android.permission.MOUNT_FORMAT_FILESYSTEMS"></uses-permission>
        <uses-permission
android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>
        <uses-permission 
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <application android:icon="@drawable/icon"
                android:debuggable="true" android:label="@string/app_name">
                <activity android:name=".DeployRSync" 
android:label="@string/app_name">
                        <intent-filter>
                                <action 
android:name="android.intent.action.MAIN" />
                                <category 
android:name="android.intent.category.LAUNCHER" />
                        </intent-filter>
                </activity>

        </application>
</manifest>

On Fri, Sep 16, 2011 at 2:34 PM, MCON Dev <mcon...@gmail.com> wrote:
> I get the exception at
> OutputStream out = new FileOutputStream(dst);
>
> On Fri, Sep 16, 2011 at 2:32 PM, MCON Dev <mcon...@gmail.com> wrote:
>> Hi, If I use the code below, I get java.io.FileNotFoundException :
>> /system/bin/rsync (Read-Only File system). I have one more question
>> following this for the Samsung Tablet. The emulator has a
>> /dev/block/mtdblock0 file. But the samsung tablet does not. It instead
>> has a mmcblk0. I need to know how I identify which is the right
>> /dev/block/<file to be used> for remounting ? May be forgetting my
>> basics here. Please guide me.
>>
>> public class DeployRSync extends Activity {
>>        @Override
>>        public void onCreate(Bundle savedInstanceState) {
>>                super.onCreate(savedInstanceState);
>>                setContentView(R.layout.main);
>>                runCommand("mount -o remount,rw /dev/block/mtdblock0 
>> /system", false);
>>                try {
>>                        copy(getAssets().open("rsync"), new 
>> File("/system/bin/rsync"));
>>                } catch (IOException e) {
>>                        e.printStackTrace();
>>                }
>>                runCommand("chmod 755 /system/bin/rsync", false);
>>                runCommand("mount -o remount, ro /dev/block/mtdblock0 
>> /system", false);
>>        }
>>
>>        void copy(InputStream in, File dst) throws IOException {
>>            OutputStream out = new FileOutputStream(dst);
>>
>>            // Transfer bytes from in to out
>>            byte[] buf = new byte[1024];
>>            int len;
>>            while ((len = in.read(buf)) > 0) {
>>                out.write(buf, 0, len);
>>            }
>>            in.close();
>>            out.close();
>>        }
>>
>>        private String runCommand(String command, boolean check) {
>>                try {
>>                        String env[] = new String[1] ;
>>                        env[0] = 
>> Environment.getRootDirectory().getAbsolutePath() ;
>>                    Process process ;
>>                    if (check)
>>                        process = Runtime.getRuntime().exec(command, env, new
>> File("/system/bin"));
>>                    else
>>                        process = Runtime.getRuntime().exec(command);
>>
>>                    BufferedReader reader = new BufferedReader(
>>                            new 
>> InputStreamReader(process.getInputStream()),4096);
>>                    process.getOutputStream();
>>                    int read;
>>                    char[] buffer = new char[4096];
>>                    StringBuffer output = new StringBuffer();
>>                    while ((read = reader.read(buffer)) > 0) {
>>                        output.append(buffer, 0, read);
>>                    }
>>                    reader.close();
>>
>>                    // Waits for the command to finish.
>>                    process.waitFor();
>>
>>                    return output.toString();
>>                } catch (IOException e) {
>>                        e.printStackTrace();
>>                    throw new RuntimeException(e);
>>
>>                } catch (InterruptedException e) {
>>                        e.printStackTrace();
>>                    throw new RuntimeException(e);
>>                }
>>        }
>> }
>>
>> Regards
>> Siddharth
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to