Dark Mode on Android

In this example, I am using Material Design. But you can also use the Theme.AppCompat.DayNight. This is a simple way to adapt a dark mode, if you wants more, check for GitHub or Internet. Change the style First you should use the DayNight style by Google. <style name="AppTheme" parent="Theme.MaterialComponents.DayNight"> If you want to let things easily, that’s enough. But you can also provide more adaptation. Adapt colors Make a new folder at project/app/src/main/res/values-night then make a new resource file colors.xml. Edit the color you want to set on dark mode. ...

September 5, 2020 · Aimer Neige

Android Develop Data Save

Change Package Name Quickly Sometimes, we may need to change the package name of our Android Project. Maybe the package is not suitable or we get a better package name. But that’s doesn’t matter, we just need to change it. So, how we can change a package name? Here are the solution. Open your Android Project at Android Studio. Go to the Androidmanifest.xml. Find your package name. For example com.aimerneige.test.example. Click the part you want to change, like test. Right click and select Refactor -> Rename. Select the Rename package. Enter a new package name. Click the Refactor, Do Refactor. Waiting for the operation done. That’s all. Enjoy it! ...

August 18, 2020 · Aimer Neige

Android Develop Data Save

Save data to file save data // This function will save the data of inputText into file "data" as text file // The file "data" will be saved to /data/data/com.aimerneige.example/files/data fun save(inputText: String) { try { // "data" is the name of the file you saved on phone storage // You can change it as you want val output = openFileOutput("data", Context.MODE_PRIVATE) val writer = BufferedWriter(OutputStreamWriter(output)) writer.use { it.write(inputText) } } catch (e: IOException) { e.printStackTrace() } } load data // This function will try to load the data at a file named "data" // which is on /data/data/com.aimerneige.example/files/data fun load(): String { // a StringBuilder to load data val content = StringBuilder() try { // "data" is the name of the file you want to find on disk val input = openFileInput("data") val reader = BufferedReader(InputStreamReader(input)) reader.use { reader.forEachLine { content.append(it) } } } catch (e: IOException) { e.printStackTrace() } return content.toString() } You can also use like this: ...

August 10, 2020 · Aimer Neige