caching - How do I prevent my Android app from writing any caches (app caches)? - Stack Overflow

I'm working on a simple Android app in C++Java (mostly C++). But I noticed, even with the barebon

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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信