mirror of
https://github.com/ChronosX88/Influence-P2P.git
synced 2024-11-22 07:12:19 +00:00
Added an extended class Application to get the Context from anywhere in the application, the DHT configuration (data storage folder) has been changed.
This commit is contained in:
parent
724c3c8da7
commit
ab63f87d7c
@ -5,7 +5,7 @@
|
||||
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
@ -0,0 +1,22 @@
|
||||
package io.github.chronosx88.influence;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* Extended Application class which designed for getting Context from anywhere in the application.
|
||||
*/
|
||||
|
||||
public class ExtendedApplication extends Application {
|
||||
private static Application instance;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static Context getContext() {
|
||||
return instance.getApplicationContext();
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@ package io.github.chronosx88.influence.kademlia;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import io.github.chronosx88.influence.ExtendedApplication;
|
||||
|
||||
/**
|
||||
* A set of Kademlia configuration parameters. Default values are
|
||||
* supplied and can be changed by the application as necessary.
|
||||
@ -17,7 +19,7 @@ public class DefaultConfiguration implements KadConfiguration
|
||||
private final static int K = 5;
|
||||
private final static int RCSIZE = 3;
|
||||
private final static int STALE = 1;
|
||||
private final static String LOCAL_FOLDER = "com/github/joshuakissoon/kademlia";
|
||||
private final static String LOCAL_FOLDER = "DHT_Data";
|
||||
|
||||
private final static boolean IS_TESTING = true;
|
||||
|
||||
@ -75,7 +77,7 @@ public class DefaultConfiguration implements KadConfiguration
|
||||
public String getNodeDataFolder(String ownerId)
|
||||
{
|
||||
/* Setup the main storage folder if it doesn't exist */
|
||||
String path = System.getProperty("user.home") + File.separator + DefaultConfiguration.LOCAL_FOLDER;
|
||||
String path = ExtendedApplication.getContext().getFilesDir() + File.separator + DefaultConfiguration.LOCAL_FOLDER;
|
||||
File folder = new File(path);
|
||||
if (!folder.isDirectory())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user