Skip to content

Assets Usage

Efra Espada edited this page Aug 17, 2019 · 5 revisions

Obfuscate any asset file you want.

Select the files:

stringcare {
    modules {
        app {
            assetsFiles = ["test_a.json", "raw/cipher"]
        }
    }
}

Or select a group of files:

stringcare {
    modules {
        app {
            assetsFiles = ["*.json"]
        }
    }
}

App Usage

SC is designed to retrieve JSON objects, but you can use retrieve any file you want as ByteArray.

JSON Object

Java:

JSONObject json = SC.asset().json("config.json");

// async
SC.asset().asyncJson("config.json", json -> {
   // json
});

Kotlin:

val json = "config.json".json()

// async
"config.json".asyncJson { json ->
   // json
}

JSON Array

Java:

JSONArray json = SC.asset().jsonArray("configArray.json");

// async
SC.asset().asyncJsonArray("configArray.json", json -> {
   // json
});

Kotlin:

val json = "configArray.json".jsonArray()

// async
"configArray.json".asyncJsonArray { json ->
   // json
}

ByteArray

Java:

byte[] bytes = SC.asset().bytes("config.json");

// async
SC.asset().asyncBytes("config.json", byteArray -> {
    // byteArray            
});

Kotlin:

val bytes = "config.json".bytes()

// async
"config.json".asyncBytes { bytes ->
    val value = String(bytes)
}

Retrieve Any File

You can use SC for retrive non-obfuscated files:

Java:

JSONObject json = SC.asset().json("config.json", false);
JSONArray json = SC.asset().jsonArray("configArray.json", false);
byte[] bytes = SC.asset().bytes("config.json", false);

Kotlin:

val json = "config.json".json { false }
val jsonArray = "configArray.json".jsonArray { false }
val bytes = "config.json".bytes { false }