Categories
Mastering Development

How to save a file in storage in Android Studio?

I am working on a Piano App in android which has a record functionality ,it uses the device mic to record and then saves the recorded file to the device memory. How do i correctly save a audio file in storage in an android App? . I am unable to save the file inside the […]

Categories
Mastering Development

Can someone help convert some some Kotlin to Java for an Android app?

Having a really hard time implementing the AgnaldoNP/PreviewImageCollection from Github. The sample works fine but is written in Kotlin and the IDE de-compile to Java creates an error. If anyone could help me convert the below to Java I’d be really, really grateful: collectionView.addImage(BitmapFactory.decodeResource(resources, R.drawable.landscape_08), object : ImageCollectionView.OnImageClickListener { override fun onClick(bitmap: Bitmap, imageView: ImageView) […]

Categories
Mastering Development

I have a shardpreferece class, it gives me an error I don’t know what it could be

public class SharedPreferencesManager { private static final String APP_SETTINGS_FILE = “APP_SETTINGS”; private SharedPreferencesManager() { } private static SharedPreferences getSharedPreferences() { return MyApp.getContext() .getSharedPreferences(APP_SETTINGS_FILE , Context.MODE_PRIVATE); } public static void setSomeStringValue(String dataLabel, String dataValue) { SharedPreferences.Editor editor = getSharedPreferences().edit(); editor.putString(dataLabel, dataValue); editor.commit(); } public static void setSomeBooleanValue(String dataLabel, boolean dataValue) { SharedPreferences.Editor editor = getSharedPreferences().edit(); editor.putBoolean(dataLabel, […]

Categories
Mastering Development

Casting String to Integer not working, throwing NumberFormatException

The value of walletBalance is a string, eg “150.0”. I am trying to display an error message in form of a toast in another activity(SuccessActivity) is the amount to be withdrawn from the user is less than the wallet balance. I keep getting NumberFormatException error for the value of i, so i decided to use […]

Categories
Mastering Development

Android – SharedPreferences’s getString prints the default value

I’ve tried to save the string TRUE and call it right away to check if it is successfully saved, but the result continuously spits 0, which is the default value. What is wrong with my code? SharedPreferences settings = getSharedPreferences(“PREFS”, 0); SharedPreferences.Editor editor = settings.edit(); editor.putString(“doublePoint”, “TRUE”); String doublePoint = settings.getString(“doublePoint”, “0”); Toast.makeText(getApplicationContext(), doublePoint,Toast.LENGTH_LONG).show();

Categories
Mastering Development

Upload an image in firebase [duplicate]

I am uploading an image to firebase. It is uploaded correctly but the problem is in storing that URL of firebase storage to real-time database. It was working correctly in the previous version of android but now I have updated my android studio now it’s not working can any one help me task.getResult().getDownloadUrl().toString(); I am […]

Categories
Mastering Development

How to count working days in Android Studio?

What I want to do is calculate working days from two defined dates (beginning of month and end of the month). I am working with a function that I found out which receives three parameters, start date, end date, and a list of dates of non-working days (holidays and others). The code below gives me […]

Categories
Development

I am using ffirestore for retrieving data and adding it to the list however i got an error null pointer exception.below is my code

RecyclerView testing = view.findViewById(R.id.home_page_recyclerview); LinearLayoutManager testingLayoutManager = new LinearLayoutManager(getContext()); testingLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); testing.setLayoutManager(testingLayoutManager); homePageModelList = new ArrayList<>(); testing.setAdapter(homePageAdapter); firebaseFirestore.collection(“CATEGORIES”).document(“HOME”).collection(“TOP_DEALS”) .orderBy(“index”).get() .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { @Override public void onComplete(@NonNull Task<QuerySnapshot> task) { if (task.isSuccessful()) { for(QueryDocumentSnapshot documentSnapshot: task.getResult()) { if((long)documentSnapshot.get(“view_type”)==0) { sliderModelList = new ArrayList<>(); int no_of_banners = (int) documentSnapshot.get(“number_of_banners”); for(int x =1;x==no_of_banners;x++) { sliderModelList.add(new SliderModel(documentSnapshot.get(“banner_”+x).toString(), documentSnapshot.get(“banner_”+x+”_background”).toString())); } homePageModelList.add(new […]

Categories
Development

How to access Latitude and Longitude as variables from Service?

I’m having trouble trying to get the latitude and longitude from my Service and store them as variables so I can access them from other classes I’m building. I want to have them equal to the current latitude and longitude of the user and update them through the interval set in the requestLocation() method. I […]

Categories
Development

Access denied for user ‘root; @localhost'(using password:YES) and mysqli_query()expects parameter 1 to be mysqli,bool given

I’m working on a register page and i got this problems(as what is shown in the picture)[screenshot of the problem]: https://i.stack.imgur.com/q3rA0.jpg. I’m new to php and online database so i hope you can bear with me. I’m using xampp as my server. Here’s my android studio code: public class MainActivity extends AppCompatActivity { // Creating […]