I need to see where my sharedpreferances values are stored - java

In my project, I need to see the location of my shared preference where can I see it.

SharedPreferences are stored in an XML file in the app data folder, i.e.
/data/data/YOUR_PACKAGE_NAME/shared_prefs/YOUR_PREFS_NAME.xml
or the default preferences at:
/data/data/YOUR_PACKAGE_NAME/shared_prefs/YOUR_PACKAGE_NAME_preferences.xml
SharedPreferences added during runtime are not stored in the Eclipse project.
Note: Accessing /data/data/<package_name> requires superuser privileges

Go to device File explorer at the right bottom of your android studio. From there go to data-> data->(your package)->shared preferences

Related

where does exactly getFilesDir() method address?

I have some files you can say a trained model that I need to get their path in my activity class.
I want to use getFilesDir()but it return "data/user/0/com.example.abc/files/".
I just don't know which folder or directory I have to paste my files exactly in order to be in this path so that these file can be get through getFilesDir().
This is the folder on your device
You can find it by opening "Device File Explorer" (this is a collapsed tab in the bottom right of your Android Studio - written vertically on the right edge, bottom)
There you open the folders data/data/com.yourpackage.name/files
Upload your files to this folder and your app can pick them up.
Hope this helps.
Use this way only to test things. For a production scenario you need to package your files in the project, like in the raw or assets folders of your app's resources, so they are contained in the .apk or .aab app bundle.
You can not access this folder via Windows Explorer. The Device must be in developer mode and adb must be running, so you can only access it through android studio or adb command shell. Keep that in mind.

Android Studio pointing at wrong user directory

On my machine I have two user directories, one local on C:\Users\Username\, and another on a network path \\networkName\Home\Username.
Although Android studio was stored in C:\Program Files, and the SDK folder was set to C:\Users\Username\AppData\Local\Android\sdk, Android Studio itself insists on using the network home, saving all local application data there, and as there's no space on this directory, causing Android Studio to throw constant No enough space on the disk exceptions, or file not found.
Is there an environment variable, or registry key I need to change to get it to point at the right folder?
To change the Environment variable follow the steps by #tacticurv:
1.) Open Windows explorer and right click on computer and select properties. In the control panel home that opened select advanced system settings in the left pane. Then select environment variables under advanced tab in the system properties window.
2.) Add a new user variable with name 'ANDROID_AVD_HOME' and value as path to /.android/avd/
3.) Similarly set GRADLE environment variables. This link might help - http://www.gradle.org/installation
4.) Start Android Studio - it will ask if you want to import config file. Give location to /.AndroidStudio/config

Plugin Development, where to save user data?

I am developing a plugin for Eclipse. When the user runs the application for the first time, calibration takes place. This is where user data is taken and then printed out to text files, so that when used again, the system will remember their settings.
I was wondering where is the best place to store these text files on a user's system?
There are different options with different scopes:
per installation: see the post, create a unique folder under the mentioned path and store the files there
per user: create a unique folder under the users home directory (System.getProperty("user.dir")) and store the files there
per workspace: Plugin::getStateLocation returns a path that is unique to the given plug-in for each workspace. Store your files there. Plugin is an abstract class that is implemented by the Activator or your plug-in. If you don't have such class yet, create it by specifying the Activator in the manifest editor. Alternatively you can use Platform::getStateLocation() if you have a reference to the Bundle that represents your plug-in.
A common place to store such data is the
AppData\Local\YourPluginName
directory.
You may also use the
eclipse/plugins/YourPlugin
directory.
Your plugin can store data in the workspace metadata in the plugin 'state location'
Use something like:
Bundle bundle = FrameworkUtil.getBundle(getClass());
IPath stateLoc = Platform.getStateLocation(bundle);
stateLoc will be a directory where your plugin can store whatever it likes. The location will normally be '.metadata/.plugins/your plugin id' in the workspace.

Where to find the created file in Android emulator in Windows

I created a simple file write/read app in Eclipse and have successfully tested that it could read what it wrote. The structure is fairly simple. I use FileOutputStream to write a samplefile.txt using openFileOutput and a FileInputStream using openFileInput to read it back. The only minor thing is that I don't know where is the file on my physical hard drive? Can anybody point me to where I could find the file in Windows?
If you dont give a absolute path the file will be creataed in aplication directory.
This is /data/data/packge-name-of-your-app/
e.g:
/data/data/com.example.test/
See more http://developer.android.com/training/basics/data-storage/files.html
Go to DDMS perspective, select the emulator which you are using, go to package explorer tag ,then you will get a list of folders hierarchy.
Go to /data/data/
Now you will see a list of packages installed, search for the package name of your app and expand it.
Here you will see the files which your application created when it was running.
P.S : You cannot find this file on the physical drive of your computer,because it is present in the storage of the emulated android virtual device. This storage cannot be directly accessed by you.

I can not see with db Questoid SQLite Browser

i am using eclipse for android programing and now i need to view SQLite database in the emulator.
I followed these step:
Download .jar file
Place the plugin .jar file in your Eclipse plugins folder (e.g. /usr/lib/eclipse/plugins)
Restart Eclipse
Start up an Android Emulator w/ Debugging in Eclipse
Switch to the DDMS Perspective in Eclipse
Go to the 'File Explorer' tab to locate your device's database file
Navigate to: e.g. 'data -> data -> com.myproject -> databases -> myproject
Now when i try to Open the database file in Questoid i can't select it!
(see screen shot)
same advice?
From your screen shot there, the database does not have a "." (read: period) in the file name & extension area.
Improper: mydatabaseDB
Proper: mydatabase.db
Once the database shows the proper extension (and is a proper SQLite database), then Questoid will (I use the plugin all the time in Eclipse (Juno version)) then show the "active" button (not disabled like in your screen shot). When looking for latest database entries (what was just added into the database), I then click once again on the toolbar icon as you show there, in the upper right of the screen. I then go to the Browse Data tab for that view, then choose the table from the database I want to view the fields from.
I hope this helps.
Happy coding...
I had the same problem with "sqlitemanager": only .db-Database files are accepted.
This is the solution:
Download this Questoid SqLiteBrowser: http://www.java2s.com/Code/JarDownload/com.questoid/com.questoid.sqlitebrowser_1.2.0.jar.zip
Unzip and put it into eclipse/dropins (not Plugins)
Try following these steps:
1) Close Eclipe
2) Remove the .jar from /usr/lib/eclipse/plugins.
3) Place the .jar in /eclipse/dropins and let Eclipse try to install it for you.
4) Start Eclipse.
you can always use sqlitebrowser externally . You will have to pull your databse everytime from ddms though .
The file has to end with .db extension, so the answer is to name your database as this sqlite browser expects it to be.
Another way of fixing it is to find a year old version that does not have this constraint.
Please use the extension ".db" in lowercase, please don't try with these extensions .SLQLITE, .BD, .DB, .SQL, or similar or without extensions.
Regards,

Categories