1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 06:11:19 +00:00

Create syncthing folder on start if it does not exist.

This commit is contained in:
Felix Ableitner 2014-05-05 22:30:57 +02:00
parent 92c30b55c1
commit b091d430a8
2 changed files with 18 additions and 0 deletions

View file

@ -4,7 +4,11 @@
android:versionCode="1" android:versionCode="1"
android:versionName="0.1" android:versionName="0.1"
android:debuggable="true" > android:debuggable="true" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application android:label="@string/app_name" > <application android:label="@string/app_name" >
<activity <activity
android:name="MainActivity" android:name="MainActivity"

View file

@ -2,11 +2,25 @@ package com.nutomic.syncthingandroid;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import java.io.File;
public class MainActivity extends Activity { public class MainActivity extends Activity {
private static final String TAG = "MainActivity";
private static final File SYNCTHING_FOLDER =
new File(Environment.getExternalStorageDirectory(), "syncthing");
@Override public void onCreate(Bundle savedInstanceState) { @Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (!SYNCTHING_FOLDER.isDirectory() && !SYNCTHING_FOLDER.mkdir()) {
Log.w(TAG, "Failed to create syncthing folder on sdcard, exiting");
finish();
return;
}
System.loadLibrary("syncthing"); System.loadLibrary("syncthing");
} }