Skip to content

Instantly share code, notes, and snippets.

View jebware's full-sized avatar

Jeb Ware jebware

  • Charlotte, NC
  • 15:43 (UTC -04:00)
View GitHub Profile
val file = File(context.filesDir, "config.json")
val encoded = FileUtils.readFileToString(file)
val configurationObj = gson.fromJson(encoded, FooConfiguration::class.java)
@jebware
jebware / scratch.kts
Created September 8, 2018 12:24
write to flat-file store
val file = File(context.filesDir, "config.json")
val encoded = gson.toJson(configurationObj)
FileUtils.writeStringToFile(file, encoded)
@jebware
jebware / build.gradle
Created September 8, 2018 12:22
dependencies for flat-file storage
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'org.apache.commons:commons-io:1.3.2'
@jebware
jebware / build.gradle
Created November 28, 2017 01:49
include all proguard files in a directory
proguardFiles getDefaultProguardFile('proguard-android.txt')
file('proguard').listFiles().each { proguardFile it }
@jebware
jebware / Gradle build time
Created March 6, 2015 13:42
Use gradle to put the build time as a field in your BuildConfig file.
android {
...
defaultConfig {
...
buildConfigField "String", "BUILD_TIME", "\"${buildTime()}\""
}
}
def buildTime() {
def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")