I'm working on a simple Android app in C++/Java (mostly C++). But I noticed, even with the barebones code of Java that runs C++ (JNI), it still writes caches to the internal storage. How do I stop caches from being written, even if it's too painful to code in?
App purpose: JSON Editor (no ads, no bloat)
Reasons why:
- Storage cache isn't needed for my app.
- This can waste write/erase cycles to the internal storage, which is something I don't want at all.
State of the app: Barebones. There's absolutely nothing I can do in the app for now.
What I have tried:
- Google Search
- Reduce the amount of libraries used
- Made a new project without any new code
- Removed the AppCompatActivity library too (by removing the import)
Search terms used:
- "how to prevent cache in Android apps"
- "disable caching in Android apps"
Code used:
package com.sonicandtailscd.jsoneditor;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.sonicandtailscd.jsoneditor.databinding.ActivityMainBinding;
public class MainActivity extends AppCompatActivity {
// Used to load the 'jsoneditor' library on application startup.
static {
System.loadLibrary("jsoneditor");
}
private ActivityMainBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
// Example of a call to a native method
TextView tv = binding.sampleText;
tv.setText(stringFromJNI());
}
/**
* A native method that is implemented by the 'jsoneditor' native library,
* which is packaged with this application.
*/
public native String stringFromJNI();
}
Proof of such caches: Image of my phone screen showing that cache was written
What do you believe is causing this? AppCompatActivity
and Android itself.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744893709a4599568.html
评论列表(0条)